| 41 | """ |
| 42 | |
| 43 | def main(): |
| 44 | parser = argparse.ArgumentParser('algo', description = "algo [<cmd>] [options] [<args>...] [--help] [--profile]") |
| 45 | |
| 46 | subparsers = parser.add_subparsers(help = 'sub cmd',dest = 'cmd') |
| 47 | |
| 48 | parser_auth = subparsers.add_parser('auth', help = 'save api key and api address for profile') |
| 49 | parser_auth.add_argument('--profile', action = 'store', type = str, default = 'default') |
| 50 | |
| 51 | parser_clone = subparsers.add_parser('clone', help = 'clone <algo> clone the algorithm repository') |
| 52 | parser_clone.add_argument('algo') |
| 53 | parser_clone.add_argument('--profile', action = 'store', type = str, default = 'default') |
| 54 | |
| 55 | #parse options for the run command |
| 56 | parser_run = subparsers.add_parser('run', help = 'algo run <algo> [input options] <args..> [output options] run an algorithm') |
| 57 | |
| 58 | parser_run.add_argument('algo') |
| 59 | parser_run.add_argument('-d','--data', action = 'store', help = 'detect input type', default = None) |
| 60 | parser_run.add_argument('-t','--text', action = 'store', help = 'treat input as text', default = None) |
| 61 | parser_run.add_argument('-j','--json', action = 'store', help = 'treat input as json data', default = None) |
| 62 | parser_run.add_argument('-b','--binary', action = 'store', help = 'treat input as binary data', default = None) |
| 63 | parser_run.add_argument('-D','--data-file', action = 'store', help = 'specify a path to an input file', default = None) |
| 64 | parser_run.add_argument('-T','--text-file', action = 'store', help = 'specify a path to a text file', default = None) |
| 65 | parser_run.add_argument('-J','--json-file', action = 'store', help = 'specify a path to a json file', default = None) |
| 66 | parser_run.add_argument('-B','--binary-file', action = 'store', help = 'specify a path to a binary file', default = None) |
| 67 | parser_run.add_argument('--timeout', action = 'store',type = int, default = 300, help = 'specify a timeout (seconds)') |
| 68 | parser_run.add_argument('--debug', action = 'store_true', help = 'print the stdout from the algo <this only works for the owner>') |
| 69 | parser_run.add_argument('--profile', action = 'store', type = str, default = 'default') |
| 70 | parser_run.add_argument('-o', '--output', action = 'store', default = None, type = str) |
| 71 | |
| 72 | #subparser for ls |
| 73 | parser_ls = subparsers.add_parser('ls', help = 'ls [-l] [directory] list the contents of a directory', ) |
| 74 | |
| 75 | parser_ls.add_argument('-l', '--long', action = 'store_true') |
| 76 | parser_ls.add_argument('path', nargs = '?', default = None) |
| 77 | parser_ls.add_argument('--profile', action = 'store', type = str, default = 'default') |
| 78 | |
| 79 | #subparser for rm |
| 80 | parser_rm = subparsers.add_parser('rm', help = 'rm <path> remove a file', ) |
| 81 | |
| 82 | parser_rm.add_argument('path', nargs = '?', default = None) |
| 83 | parser_rm.add_argument('--profile', action = 'store', type = str, default = 'default') |
| 84 | |
| 85 | #subparser for mkdir |
| 86 | parser_mkdir = subparsers.add_parser('mkdir', help = 'mkdir <directory> create a directory') |
| 87 | |
| 88 | parser_mkdir.add_argument('path', help = 'directory to create') |
| 89 | parser_mkdir.add_argument('--profile', action = 'store', type = str, default = 'default') |
| 90 | |
| 91 | #subparser for rmdir |
| 92 | parser_rmdir = subparsers.add_parser('rmdir', help = 'rmdir [-f] <directory> remove a directory') |
| 93 | |
| 94 | parser_rmdir.add_argument('-f', '--force', action = 'store_true', help = 'force directory removal if it is not empty') |
| 95 | parser_rmdir.add_argument('path', help = 'directory to remove') |
| 96 | parser_rmdir.add_argument('--profile', action = 'store', type = str, default = 'default') |
| 97 | |
| 98 | #subparser for cp |
| 99 | parser_cp = subparsers.add_parser('cp', help = 'cp <src,...> <dest> copy file(s) to the destination',) |
| 100 | |