Example #1
0
def main():
    commands = load_commands()

    args = docopt(root_doc(), version='dokku-client version %s' % __version__, options_first=True)
    command_name = args['<command>'] or 'help'

    if command_name == 'version':
        # docopt will handle version printing for us if use '--version'
        exit(call(['dokku-client', '--version']))

    # Get the command object for the specified command name
    command = command_by_name(command_name, commands)
    if not command:
        sys.stderr.write("Unknown command. Use 'dokku-client help' for list of commands.\n")
        exit(1)
    else:
        # Use docopt to parse the options based upon the class' doc string
        command_args = docopt(command.doc)
        # Load default values from the users' environment
        command_args = apply_defaults(command_args)
        if command.check_config:
            # Sanity check the config
            if not command_args.get('--host', None):
                sys.stderr.write("Could not determine host. Specify --host or set DOKKU_HOST.\n")
                exit(1)
            if not command_args.get('--app', None):
                sys.stderr.write("Could not determine app. Specify --app or set DOKKU_APP.\n")
                exit(1)
        # Ok, let's run the command
        command.args = command_args
        command.main()
Example #2
0
 def main(self):
     if not self.args['COMMAND']:
         print root_doc()
     else:
         command = command_by_name(self.args['COMMAND'])
         if not command:
             sys.stderr.write("Unknown command. Use 'dokku-client help' for list of commands.\n")
         else:
             print command.doc
Example #3
0
 def main(self):
     if not self.args['COMMAND']:
         print root_doc()
     else:
         command = command_by_name(self.args['COMMAND'])
         if not command:
             sys.stderr.write(
                 "Unknown command. Use 'dokku-client help' for list of commands.\n"
             )
         else:
             print command.doc