(args_in)
return results
Check to ensure valid arguments were passed in and provides guidance
    on the available options if not
Check to ensure valid arguments were passed in and provides guidance
    on the available options if not
Check to ensure valid arguments were passed in and provides guidance on the available options if not
def check_args(args_in):
    """
    Check to ensure valid arguments were passed in and provides guidance
    on the available options if not
    """
    parser = argparse.ArgumentParser(
        description='InterPlanetary Wayback (ipwb)', prog="ipwb")
    subparsers = parser.add_subparsers(
        title="ipwb commands",
        description=("Invoke using \"ipwb <command>\""
                     ", e.g., ipwb replay <cdxjFile>"))

    index_parser = subparsers.add_parser(
        'index',
        prog="ipwb",
        description="Index a WARC file for replay in ipwb",
        help="Index a WARC file for replay in ipwb")
    index_parser.add_argument(
        'warc_path',
        help="Path to a WARC[.gz] file",
        metavar="index <warc_path>",
        nargs='+',
        default=None)
    index_parser.add_argument(
        '-e',
        help="Encrypt WARC content prior to adding to IPFS",
        action='store_true',
        default=False)
    index_parser.add_argument(
        '-c',
        help='Compress WARC content prior to adding to IPFS',
        action='store_true',
        default=False)
    index_parser.add_argument(
        '--compressFirst',
        help='Compress data before encryption, where applicable',
        action='store_true',
        default=False)
    index_parser.add_argument(
        '-o', '--outfile',
        help='Path to an output CDXJ file, defaults to STDOUT',
        default=None)
    index_parser.add_argument(
        '--debug',
        help='Convenience flag to help with testing and debugging',
        action='store_true',
        default=False)
    index_parser.set_defaults(func=check_args_index)

    replay_parser = subparsers.add_parser(
        'replay',
        prog="ipwb replay",
        description="Start the ipwb relay system",
        help="Start the ipwb replay system")
    replay_parser.add_argument(
        'index',
        help='path, URI, or multihash of file to use for replay',
        nargs='?')
    replay_parser.add_argument(
        '-P', '--proxy',
        help='Proxy URL',
        metavar='<host:port>',
        nargs='?')
    replay_parser.set_defaults(func=check_args_replay,
                               onError=replay_parser.print_help)

    parser.add_argument(
        '-d', '--daemon',
        help=("Multi-address of IPFS daemon "
              "(default /dns/localhost/tcp/5001/http)"),
        default=util.IPFSAPI_MUTLIADDRESS,
        dest='daemon_address')
    parser.add_argument(
        '-v', '--version', help='Report the version of ipwb', action='version',
        version=f'InterPlanetary Wayback {ipwb_version}')
    parser.add_argument(
        '-u', '--update-check',
        action='store_true',
        help='Check whether an updated version of ipwb is available'
        )
    parser.set_defaults(func=util.check_for_update)

    arg_count = len(args_in)
    cmd_list = ['index', 'replay']
    base_parser_flag_list = ['-d', '--daemon', '-v', '--version',
                             '-u', '--update-check']

    # Various invocation error, used to show appropriate help
    cmd_error_index = arg_count == 2 and args_in[1] == 'index'
    cmd_error_no_command = arg_count == 1
    cmd_error_invalid_command = arg_count > 1 \
        and args_in[1] not in cmd_list + base_parser_flag_list

    if cmd_error_no_command or cmd_error_invalid_command:
        parser.print_help()
        sys.exit()
    elif cmd_error_index:
        index_parser.print_help()
        sys.exit()

    results = parser.parse_args()
    results.func(results)

    return results
def check_args ( args_in ) : parser = argparse . ArgumentParser ( description = 'InterPlanetary Wayback (ipwb)' , prog = "ipwb" ) subparsers = parser . add_subparsers ( title = "ipwb commands" , description = ( "Invoke using \"ipwb <command>\"" ", e.g., ipwb replay <cdxjFile>" ) ) index_parser = subparsers . add_parser ( 'index' , prog = "ipwb" , description = "Index a WARC file for replay in ipwb" , help = "Index a WARC file for replay in ipwb" ) index_parser . add_argument ( 'warc_path' , help = "Path to a WARC[.gz] file" , metavar = "index <warc_path>" , nargs = '+' , default = None ) index_parser . add_argument ( '-e' , help = "Encrypt WARC content prior to adding to IPFS" , action = 'store_true' , default = False ) index_parser . add_argument ( '-c' , help = 'Compress WARC content prior to adding to IPFS' , action = 'store_true' , default = False ) index_parser . add_argument ( '--compressFirst' , help = 'Compress data before encryption, where applicable' , action = 'store_true' , default = False ) index_parser . add_argument ( '-o' , '--outfile' , help = 'Path to an output CDXJ file, defaults to STDOUT' , default = None ) index_parser . add_argument ( '--debug' , help = 'Convenience flag to help with testing and debugging' , action = 'store_true' , default = False ) index_parser . set_defaults ( func = check_args_index ) replay_parser = subparsers . add_parser ( 'replay' , prog = "ipwb replay" , description = "Start the ipwb relay system" , help = "Start the ipwb replay system" ) replay_parser . add_argument ( 'index' , help = 'path, URI, or multihash of file to use for replay' , nargs = '?' ) replay_parser . add_argument ( '-P' , '--proxy' , help = 'Proxy URL' , metavar = '<host:port>' , nargs = '?' ) replay_parser . set_defaults ( func = check_args_replay , onError = replay_parser . print_help ) parser . add_argument ( '-d' , '--daemon' , help = ( "Multi-address of IPFS daemon " "(default /dns/localhost/tcp/5001/http)" ) , default = util . IPFSAPI_MUTLIADDRESS , dest = 'daemon_address' ) parser . add_argument ( '-v' , '--version' , help = 'Report the version of ipwb' , action = 'version' , version = f'InterPlanetary Wayback {ipwb_version}' ) parser . add_argument ( '-u' , '--update-check' , action = 'store_true' , help = 'Check whether an updated version of ipwb is available' ) parser . set_defaults ( func = util . check_for_update ) arg_count = len ( args_in ) cmd_list = [ 'index' , 'replay' ] base_parser_flag_list = [ '-d' , '--daemon' , '-v' , '--version' , '-u' , '--update-check' ] # Various invocation error, used to show appropriate help cmd_error_index = arg_count == 2 and args_in [ 1 ] == 'index' cmd_error_no_command = arg_count == 1 cmd_error_invalid_command = arg_count > 1 and args_in [ 1 ] not in cmd_list + base_parser_flag_list if cmd_error_no_command or cmd_error_invalid_command : parser . print_help ( ) sys . exit ( ) elif cmd_error_index : index_parser . print_help ( ) sys . exit ( ) results = parser . parse_args ( ) results . func ( results ) return results