예제 #1
0
파일: complete.py 프로젝트: asteven/cli
 def run(self):
     """Overload Application.run to handle bash completion calls.
     """
     log.debug("{}.run".format(self.__class__.__name__))
     parser = self.argparser_factory(add_help=False, argv=self.argv, stdout=self.stdout, stderr=self.stderr)
     for (args, kwargs) in self.__arguments:
         parser.add_argument(*args, **kwargs)
     args, rest = parser.parse_known_args(self.argv[1:])
     if args.bash_eval:
         print ('complete -C "{} --bash-complete" {}'.format(self.argv[0], self.argv[0]))
         sys.exit(0)
     elif args.bash_complete:
         log.debug("self.argv: {}".format(self.argv))
         first = self.argv[2]
         current = self.argv[3]
         previous = self.argv[4]
         line = os.environ["COMP_LINE"]
         index = os.environ["COMP_POINT"]
         words = line.split()
         # exclude bash completion related actions from completion
         actions = dict(
             [(name, action) for name, action in self.actions.items() if name not in ("bash_complete", "bash_eval")]
         )
         completer = CommandCompleter(actions)
         candidates = completer.complete(first, current, previous, words, index)
         log.debug("CompletionMixin candidates: %s", candidates)
         print "\n".join(candidates)
         sys.exit(0)
     else:
         Application.run(self)
예제 #2
0
 def setup(self):
     Application.setup(self)
     CommandLineMixin.setup(self)
     LoggingMixin.setup(self)
예제 #3
0
 def pre_run(self):
     Application.pre_run(self)
     CommandLineMixin.pre_run(self)
     LoggingMixin.pre_run(self)
예제 #4
0
파일: daemon.py 프로젝트: cottrell/cli
 def pre_run(self):
     Application.pre_run(self)
     CommandLineMixin.pre_run(self)
     LoggingMixin.pre_run(self)
예제 #5
0
 def __init__(self, main=None, **kwargs):
     CommandLineMixin.__init__(self, **kwargs)
     LoggingMixin.__init__(self, **kwargs)
     Application.__init__(self, main, **kwargs)
예제 #6
0
파일: daemon.py 프로젝트: cottrell/cli
 def setup(self):
     Application.setup(self)
     CommandLineMixin.setup(self)
     LoggingMixin.setup(self)
     DaemonizingMixin.setup(self)
예제 #7
0
파일: daemon.py 프로젝트: cottrell/cli
 def __init__(self, main=None, **kwargs):
     DaemonizingMixin.__init__(self, **kwargs)
     LoggingMixin.__init__(self, **kwargs)
     CommandLineMixin.__init__(self, **kwargs)
     Application.__init__(self, main, **kwargs)
예제 #8
0
파일: commands.py 프로젝트: whilp/tsar
 def pre_run(self):
     # Let Command run the CommandLineMixin.pre_run()
     Application.pre_run(self)
     LoggingMixin.pre_run(self)
예제 #9
0
파일: commands.py 프로젝트: whilp/tsar
 def pre_run(self):
     # SubCommands need to set up their own logging.
     Application.pre_run(self)
     CommandLineMixin.pre_run(self)
예제 #10
0
from cli.app import Application

if __name__ == '__main__':

    Application.clear()
    app = Application()
    try:
        app.cmdloop()
    except KeyboardInterrupt:
        del app
        Application.clear()