Exemplo n.º 1
0
 def create_parser(self, prog_name, subcommand):
     parser = CommandParser(self,
                            prog="%s %s" %
                            (os.path.basename(prog_name), subcommand),
                            description=u'API文档辅助生成脚本.',
                            add_help=False)
     parser.set_defaults(
         **{
             'verbosity': 1,
             'pythonpath': None,
             'traceback': None,
             'no_color': False,
             'settings': None
         })
     parser._positionals = parser.add_argument_group(u'位置参数')
     parser._optionals = parser.add_argument_group(u'关键字参数')
     parser.add_argument('--no-static',
                         dest='no_static_files',
                         action='store_true',
                         default=False,
                         help=u'打包静态文件(默认添加)')
     parser.add_argument('--linux',
                         dest='linux',
                         action='store_true',
                         default=False,
                         help=u'打包Linux安装包')
     parser.add_argument('--debug',
                         dest='debug',
                         action='store_true',
                         default=False,
                         help=u'调试模式')
     parser.add_argument('-h', '--help', action='help', help=u'显示帮助信息')
     self.parser = parser
     return parser
Exemplo n.º 2
0
 def add_arguments(self, parser: CommandParser) -> None:
     """
     Adds the relevant command line arguments
     """
     parser.add_argument("-l",
                         "--logfile",
                         type=str,
                         help='The path to the log file',
                         default='/var/log/carrot.log')
     parser.add_argument(
         '--no-scheduler',
         dest='run_scheduler',
         action='store_false',
         default=False,
         help='Do not start scheduled tasks (only runs consumer sets)')
     parser.set_defaults(run_scheduler=True)
     parser.set_defaults(testmode=False)
     parser.add_argument('--loglevel',
                         type=str,
                         default='DEBUG',
                         help='The logging level. Must be one of DEBUG, '
                         'INFO, WARNING, ERROR, CRITICAL')
     parser.add_argument(
         '--testmode',
         dest='testmode',
         action='store_true',
         default=False,
         help=
         'Run in test mode. Prevents the command from running as a service. Should only be '
         'used when running Carrot\'s tests')
Exemplo n.º 3
0
    def add_arguments(self, parser: CommandParser) -> None:
        """
        This Command inherits the same arguments as :class:`carrot.management.commands.carrot.Command`, with the
        addition of one positional argument: **mode**
        """
        parser.add_argument('mode')
        parser.add_argument("-l",
                            "--logfile",
                            type=str,
                            help='The path to the log file',
                            default='/var/log/carrot.log')
        parser.add_argument("-p",
                            "--pidfile",
                            type=str,
                            help='The path to the pid file',
                            default='/var/run/carrot.pid')
        parser.add_argument(
            '--no-scheduler',
            dest='run_scheduler',
            action='store_false',
            default=False,
            help='Do not start scheduled tasks (only runs consumer sets)')
        parser.add_argument(
            '--hard',
            dest='force',
            action='store_true',
            default=False,
            help=
            'Force stop the consumer (can only be used with stop|restart modes). USE WITH CAUTION'
        )
        parser.set_defaults(run_scheduler=True)
        parser.set_defaults(testmode=False)

        parser.add_argument('--consumer-class',
                            type=str,
                            help='The consumer class to use',
                            default='carrot.objects.Consumer')
        parser.add_argument('--loglevel',
                            type=str,
                            default='DEBUG',
                            help='The logging level. Must be one of DEBUG, '
                            'INFO, WARNING, ERROR, CRITICAL')
        parser.add_argument(
            '--testmode',
            dest='testmode',
            action='store_true',
            default=False,
            help=
            'Run in test mode. Prevents the command from running as a service. Should only be '
            'used when running Carrot\'s tests')
Exemplo n.º 4
0
 def create_parser(self, prog_name, subcommand):
     parser = CommandParser(self,
                            prog="%s %s" %
                            (os.path.basename(prog_name), subcommand),
                            description=u'API文档辅助生成脚本.',
                            add_help=False)
     parser.set_defaults(
         **{
             'verbosity': 1,
             'pythonpath': None,
             'traceback': None,
             'no_color': False,
             'settings': None
         })
     parser._positionals = parser.add_argument_group(u'位置参数')
     parser._optionals = parser.add_argument_group(u'关键字参数')
     parser.add_argument(
         'ref',
         nargs='?',
         help=u'引用的对象(eg. oeauth.User, commons.login, users)')
     parser.add_argument('-t', dest='target', help=u'请求的URL的对象(eg. users)')
     parser.add_argument('-p', dest='prefix', help=u'请求的URL的前缀(eg. auth)')
     parser.add_argument(
         '-m',
         dest='mode',
         default='ILRCUAD',
         help=u'包含的模式(Info/Create/List/Get/Update/Delete, eg. iclruad)')
     parser.add_argument('-o', dest='output', help=u'保存文件名(allinone模式)')
     parser.add_argument('-u',
                         '--update',
                         dest='update',
                         action='store_true',
                         default=False,
                         help=u'覆盖已经存在的文件(默认不覆盖)')
     parser.add_argument('-i',
                         '--interactive',
                         dest='interactive',
                         action='store_true',
                         default=False,
                         help=u'覆盖前询问(默认不询问)')
     parser.add_argument('-s',
                         '--sign',
                         dest='sign',
                         action='store_true',
                         default=False,
                         help=u'添加文档签名(默认不添加)')
     parser.add_argument('-a',
                         '--allinone',
                         dest='allinone',
                         action='store_true',
                         default=False,
                         help=u'合并到单个rst文件中(默认不合并)')
     parser.add_argument('-f',
                         '--form-request',
                         dest='form_request',
                         action='store_true',
                         default=False,
                         help=u'表单请求方式(URL请求只包含GET/POST)')
     parser.add_argument('-h', '--help', action='help', help=u'显示帮助信息')
     self.parser = parser
     return parser