()
return parser
Builds and returns the argument parser.
Builds and returns the argument parser.
Builds and returns the argument parser .
def _get_argparser():
    """Builds and returns the argument parser."""
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-q', '--quiet', action='store_true',
        help='suppresses inessential messages')
    parser.add_argument(
        '--debug', action='store_true',
        help='write extra messages for debugging the tool')

    subparsers = parser.add_subparsers(
        title='Commands')

    sp_stats = subparsers.add_parser(
        'stats',
        help='displays stats about one or more carts')
    sp_stats.add_argument(
        '--csv', action='store_true',
        help='output a CSV file instead of text')
    sp_stats.add_argument(
        'filename', type=str, nargs='+',
        help='the names of files to process')
    sp_stats.set_defaults(func=stats)

    sp_listlua = subparsers.add_parser(
        'listlua',
        help='lists the Lua code for a cart to the console')
    sp_listlua.add_argument(
        'filename', type=str, nargs='+',
        help='the names of files to process')
    sp_listlua.add_argument(
        '--show-line-numbers', action='store_true',
        help='prepends each line with a line number')
    sp_listlua.add_argument(
        '--pure-lua', action='store_true',
        help='converts PICO-8 syntax extensions to pure Lua')
    sp_listlua.set_defaults(func=listlua)

    sp_listrawlua = subparsers.add_parser(
        'listrawlua',
        help='lists the Lua code for a cart to the console without parsing it')
    sp_listrawlua.add_argument(
        'filename', type=str, nargs='+',
        help='the names of files to process')
    sp_listrawlua.add_argument(
        '--show-line-numbers', action='store_true',
        help='prepends each line with a line number')
    sp_listrawlua.set_defaults(func=listrawlua)

    sp_writep8 = subparsers.add_parser(
        'writep8',
        help='converts a .p8.png cart to a .p8 cart')
    sp_writep8.add_argument(
        'filename', type=str, nargs='+',
        help='the names of files to process')
    sp_writep8.set_defaults(func=do_writep8)

    sp_luamin = subparsers.add_parser(
        'luamin',
        help='minifies the Lua code for a cart, reducing the character count')
    sp_luamin.add_argument(
        'filename', type=str, nargs='+',
        help='the names of files to process')
    sp_luamin.add_argument(
        '--keep-all-names', action='store_true',
        help='preserves all variable, property, and label names')
    # sp_luamin.add_argument(
    #     '--keep-property-names', action='store_true',
    #     help='preserves property names')
    sp_luamin.add_argument(
        '--keep-names-from-file', type=str, action='store',
        help='preserves names found in the given text file')
    sp_luamin.set_defaults(func=do_luamin)

    sp_luafmt = subparsers.add_parser(
        'luafmt',
        help='make the Lua code for a cart easier to read by adjusting '
             'indentation')
    sp_luafmt.add_argument(
        '--indentwidth', type=int, action='store', default=2,
        help='for luafmt, the indent width as a number of spaces')
    sp_luafmt.add_argument(
        '--overwrite', action='store_true',
        help='for luafmt, given a filename, overwrites the original file '
        'instead of creating a separate *_fmt.p8 file')
    sp_luafmt.add_argument(
        'filename', type=str, nargs='+',
        help='the names of files to process')
    sp_luafmt.set_defaults(func=do_luafmt)

    sp_luafind = subparsers.add_parser(
        'luafind',
        help='finds a string or pattern in the code of one or more carts')
    sp_luafind.add_argument(
        '--listfiles', action='store_true',
        help='for luafind, only list filenames, do not print matching lines')
    sp_luafind.add_argument(
        'filename', type=str, nargs='+',
        help='the names of files to process')
    sp_luafind.set_defaults(func=luafind)

    sp_listtokens = subparsers.add_parser(
        'listtokens',
        help='lists the tokens for a cart to the console (for debugging '
             'picotool)')
    sp_listtokens.add_argument(
        'filename', type=str, nargs='+',
        help='the names of files to process')
    sp_listtokens.set_defaults(func=listtokens)

    sp_printast = subparsers.add_parser(
        'printast',
        help='prints the picotool parser tree to the console (for debugging '
             'picotool)')
    sp_printast.add_argument(
        'filename', type=str, nargs='+',
        help='the names of files to process')
    sp_printast.set_defaults(func=printast)

    sp_build = subparsers.add_parser(
        'build',
        help='builds a cart out of multiple files')
    sp_build.add_argument(
        '--lua', type=str,
        help='filename for the cart (.p8 .p8.png) or Lua source file (.lua) '
             'to use for the lua region')
    sp_build.add_argument(
        '--empty-lua', action='store_true',
        help='use an empty lua region (overrides default)')
    sp_build.add_argument(
        '--lua-path', type=str,
        help='the load path to use with require() statements')
    sp_build.add_argument(
        '--optimize-tokens', action='store_true',
        help='attempt to reduce the number of Lua tokens in the final cart')
    sp_build.add_argument(
        '--lua-format', action='store_true',
        help='clean up Lua formatting in the final cart')
    sp_build.add_argument(
        '--lua-minify', action='store_true',
        help='minify the number of Lua characters in the final cart '
             '(opposite of --lua-format)')
    sp_build.add_argument(
        '--keep-all-names', action='store_true',
        help='when minifying, preserves all variable, property, '
             'and label names')
    # sp_build.add_argument(
    #     '--keep-property-names', action='store_true',
    #     help='when minifying, preserves property names')
    sp_build.add_argument(
        '--keep-names-from-file', type=str, action='store',
        help='when minifying, preserves names found in the given text file')
    sp_build.add_argument(
        '--gfx', type=str,
        help='filename for the cart whose gfx region to use')
    sp_build.add_argument(
        '--empty-gfx', action='store_true',
        help='use an empty gfx region (overrides default)')
    sp_build.add_argument(
        '--gff', type=str,
        help='filename for the cart whose gff (flags) region to '
             'use')
    sp_build.add_argument(
        '--empty-gff', action='store_true',
        help='use an empty gff (flags) region (overrides default)')
    sp_build.add_argument(
        '--map', type=str,
        help='filename for the cart whose map region to use')
    sp_build.add_argument(
        '--empty-map', action='store_true',
        help='use an empty map region (overrides default)')
    sp_build.add_argument(
        '--sfx', type=str,
        help='filename for the cart whose sfx region to use')
    sp_build.add_argument(
        '--empty-sfx', action='store_true',
        help='use an empty sfx region (overrides default)')
    sp_build.add_argument(
        '--music', type=str,
        help='filename for the cart whose music region to use')
    sp_build.add_argument(
        '--empty-music', action='store_true',
        help='use an empty music region (overrides default)')
    sp_build.add_argument(
        'filename', type=str,
        help='filename of the output cart; if the file exists, '
             'the cart is used as the default input for each region not '
             'overridden')
    sp_build.set_defaults(func=build.do_build)

    return parser
def _get_argparser ( ) : parser = argparse . ArgumentParser ( ) parser . add_argument ( '-q' , '--quiet' , action = 'store_true' , help = 'suppresses inessential messages' ) parser . add_argument ( '--debug' , action = 'store_true' , help = 'write extra messages for debugging the tool' ) subparsers = parser . add_subparsers ( title = 'Commands' ) sp_stats = subparsers . add_parser ( 'stats' , help = 'displays stats about one or more carts' ) sp_stats . add_argument ( '--csv' , action = 'store_true' , help = 'output a CSV file instead of text' ) sp_stats . add_argument ( 'filename' , type = str , nargs = '+' , help = 'the names of files to process' ) sp_stats . set_defaults ( func = stats ) sp_listlua = subparsers . add_parser ( 'listlua' , help = 'lists the Lua code for a cart to the console' ) sp_listlua . add_argument ( 'filename' , type = str , nargs = '+' , help = 'the names of files to process' ) sp_listlua . add_argument ( '--show-line-numbers' , action = 'store_true' , help = 'prepends each line with a line number' ) sp_listlua . add_argument ( '--pure-lua' , action = 'store_true' , help = 'converts PICO-8 syntax extensions to pure Lua' ) sp_listlua . set_defaults ( func = listlua ) sp_listrawlua = subparsers . add_parser ( 'listrawlua' , help = 'lists the Lua code for a cart to the console without parsing it' ) sp_listrawlua . add_argument ( 'filename' , type = str , nargs = '+' , help = 'the names of files to process' ) sp_listrawlua . add_argument ( '--show-line-numbers' , action = 'store_true' , help = 'prepends each line with a line number' ) sp_listrawlua . set_defaults ( func = listrawlua ) sp_writep8 = subparsers . add_parser ( 'writep8' , help = 'converts a .p8.png cart to a .p8 cart' ) sp_writep8 . add_argument ( 'filename' , type = str , nargs = '+' , help = 'the names of files to process' ) sp_writep8 . set_defaults ( func = do_writep8 ) sp_luamin = subparsers . add_parser ( 'luamin' , help = 'minifies the Lua code for a cart, reducing the character count' ) sp_luamin . add_argument ( 'filename' , type = str , nargs = '+' , help = 'the names of files to process' ) sp_luamin . add_argument ( '--keep-all-names' , action = 'store_true' , help = 'preserves all variable, property, and label names' ) # sp_luamin.add_argument( #     '--keep-property-names', action='store_true', #     help='preserves property names') sp_luamin . add_argument ( '--keep-names-from-file' , type = str , action = 'store' , help = 'preserves names found in the given text file' ) sp_luamin . set_defaults ( func = do_luamin ) sp_luafmt = subparsers . add_parser ( 'luafmt' , help = 'make the Lua code for a cart easier to read by adjusting ' 'indentation' ) sp_luafmt . add_argument ( '--indentwidth' , type = int , action = 'store' , default = 2 , help = 'for luafmt, the indent width as a number of spaces' ) sp_luafmt . add_argument ( '--overwrite' , action = 'store_true' , help = 'for luafmt, given a filename, overwrites the original file ' 'instead of creating a separate *_fmt.p8 file' ) sp_luafmt . add_argument ( 'filename' , type = str , nargs = '+' , help = 'the names of files to process' ) sp_luafmt . set_defaults ( func = do_luafmt ) sp_luafind = subparsers . add_parser ( 'luafind' , help = 'finds a string or pattern in the code of one or more carts' ) sp_luafind . add_argument ( '--listfiles' , action = 'store_true' , help = 'for luafind, only list filenames, do not print matching lines' ) sp_luafind . add_argument ( 'filename' , type = str , nargs = '+' , help = 'the names of files to process' ) sp_luafind . set_defaults ( func = luafind ) sp_listtokens = subparsers . add_parser ( 'listtokens' , help = 'lists the tokens for a cart to the console (for debugging ' 'picotool)' ) sp_listtokens . add_argument ( 'filename' , type = str , nargs = '+' , help = 'the names of files to process' ) sp_listtokens . set_defaults ( func = listtokens ) sp_printast = subparsers . add_parser ( 'printast' , help = 'prints the picotool parser tree to the console (for debugging ' 'picotool)' ) sp_printast . add_argument ( 'filename' , type = str , nargs = '+' , help = 'the names of files to process' ) sp_printast . set_defaults ( func = printast ) sp_build = subparsers . add_parser ( 'build' , help = 'builds a cart out of multiple files' ) sp_build . add_argument ( '--lua' , type = str , help = 'filename for the cart (.p8 .p8.png) or Lua source file (.lua) ' 'to use for the lua region' ) sp_build . add_argument ( '--empty-lua' , action = 'store_true' , help = 'use an empty lua region (overrides default)' ) sp_build . add_argument ( '--lua-path' , type = str , help = 'the load path to use with require() statements' ) sp_build . add_argument ( '--optimize-tokens' , action = 'store_true' , help = 'attempt to reduce the number of Lua tokens in the final cart' ) sp_build . add_argument ( '--lua-format' , action = 'store_true' , help = 'clean up Lua formatting in the final cart' ) sp_build . add_argument ( '--lua-minify' , action = 'store_true' , help = 'minify the number of Lua characters in the final cart ' '(opposite of --lua-format)' ) sp_build . add_argument ( '--keep-all-names' , action = 'store_true' , help = 'when minifying, preserves all variable, property, ' 'and label names' ) # sp_build.add_argument( #     '--keep-property-names', action='store_true', #     help='when minifying, preserves property names') sp_build . add_argument ( '--keep-names-from-file' , type = str , action = 'store' , help = 'when minifying, preserves names found in the given text file' ) sp_build . add_argument ( '--gfx' , type = str , help = 'filename for the cart whose gfx region to use' ) sp_build . add_argument ( '--empty-gfx' , action = 'store_true' , help = 'use an empty gfx region (overrides default)' ) sp_build . add_argument ( '--gff' , type = str , help = 'filename for the cart whose gff (flags) region to ' 'use' ) sp_build . add_argument ( '--empty-gff' , action = 'store_true' , help = 'use an empty gff (flags) region (overrides default)' ) sp_build . add_argument ( '--map' , type = str , help = 'filename for the cart whose map region to use' ) sp_build . add_argument ( '--empty-map' , action = 'store_true' , help = 'use an empty map region (overrides default)' ) sp_build . add_argument ( '--sfx' , type = str , help = 'filename for the cart whose sfx region to use' ) sp_build . add_argument ( '--empty-sfx' , action = 'store_true' , help = 'use an empty sfx region (overrides default)' ) sp_build . add_argument ( '--music' , type = str , help = 'filename for the cart whose music region to use' ) sp_build . add_argument ( '--empty-music' , action = 'store_true' , help = 'use an empty music region (overrides default)' ) sp_build . add_argument ( 'filename' , type = str , help = 'filename of the output cart; if the file exists, ' 'the cart is used as the default input for each region not ' 'overridden' ) sp_build . set_defaults ( func = build . do_build ) return parser