<commit_before>#lang scribble/doc
@require["mz.ss"
         (for-label scheme/cmdline)]

@title{Command-Line Parsing}

@note-lib[scheme/cmdline]

@defform/subs[#:literals (multi once-each once-any final jelp-labels args 
                          help-labels =>)
              (command-line optional-name-expr optional-argv-expr 
                            flag-clause ... 
                            finish-clause)
              ([optional-name-expr code:blank
                                   (code:line #:name name-expr)]
               [optional-argv-expr code:blank
                                   (code:line #:argv argv-expr)]
               [clause (code:line #:multi flag-spec ...)
                       (code:line #:once-each flag-spec ...)
                       (code:line #:once-any flag-spec ...)
                       (code:line #:final flag-spec ...)
                       (code:line #:help-labels string ...)]
                [flag-spec (flags id ... help-spec body ...+) 
                           (flags => handler-expr help-expr)]
                [flags flag-string
                       (flag-string ...+)]
                [help-spec string
                           (string-expr ...+)]
                [finish-clause code:blank
                               (code:line #:args arg-formals body ...+)
                               (code:line #:handlers handlers-exprs)]
                [arg-formals id
                             (id ...)
                             (id ...+ . id)]
                [handlers-exprs (code:line finish-expr arg-strings-expr)
                                (code:line finish-expr arg-strings-expr help-expr)
                                (code:line finish-expr arg-strings-expr help-expr
                                           unknown-expr)])]{

Parses a command line according to the specification in the
@scheme[clause]s.

The @scheme[name-expr], if provided, should produce a path or string
to be used as the program name for reporting errors when the
command-line is ill-formed. It defaults to @scheme[(find-system-path
'run-file)]. When a path is provided, only the last element of the
path is used to report an error.

The @scheme[argv-expr], if provided, must evaluate to a list or a
vector of strings. It defaults to
@scheme[(current-command-line-arguments)].

The command-line is disassembled into flags, each possibly with
flag-specific arguments, followed by (non-flag)
arguments. Command-line strings starting with @litchar{-} or<commit_msg>typo in reference<commit_after>#lang scribble/doc
@require["mz.ss"
         (for-label scheme/cmdline)]

@title{Command-Line Parsing}

@note-lib[scheme/cmdline]

@defform/subs[#:literals (multi once-each once-any final jelp-labels args 
                          help-labels =>)
              (command-line optional-name-expr optional-argv-expr 
                            flag-clause ... 
                            finish-clause)
              ([optional-name-expr code:blank
                                   (code:line #:name name-expr)]
               [optional-argv-expr code:blank
                                   (code:line #:argv argv-expr)]
               [flag-clause (code:line #:multi flag-spec ...)
                            (code:line #:once-each flag-spec ...)
                            (code:line #:once-any flag-spec ...)
                            (code:line #:final flag-spec ...)
                            (code:line #:help-labels string ...)]
                [flag-spec (flags id ... help-spec body ...+) 
                           (flags => handler-expr help-expr)]
                [flags flag-string
                       (flag-string ...+)]
                [help-spec string
                           (string-expr ...+)]
                [finish-clause code:blank
                               (code:line #:args arg-formals body ...+)
                               (code:line #:handlers handlers-exprs)]
                [arg-formals id
                             (id ...)
                             (id ...+ . id)]
                [handlers-exprs (code:line finish-expr arg-strings-expr)
                                (code:line finish-expr arg-strings-expr help-expr)
                                (code:line finish-expr arg-strings-expr help-expr
                                           unknown-expr)])]{

Parses a command line according to the specification in the
@scheme[flag-clause]s.

The @scheme[name-expr], if provided, should produce a path or string
to be used as the program name for reporting errors when the
command-line is ill-formed. It defaults to @scheme[(find-system-path
'run-file)]. When a path is provided, only the last element of the
path is used to report an error.

The @scheme[argv-expr], if provided, must evaluate to a list or a
vector of strings. It defaults to
@scheme[(current-command-line-arguments)].

The command-line is disassembled into flags, each possibly with
flag-specific arguments, followed by (non-flag)
arguments. Command-line strings starting with @litchar{-} or
{'fraction_non_alphanumeric': 0.10892646480534801, 'fraction_numerical': 0.0, 'mean_word_length': 1.4120436225699384, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5516443', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1263, 'n_words': 373}