////////////////////////////////////////////////////////////////////////////////
// 'pkg-register' subcommand.
767188
func cmdRegister(params Parameters) *subcommands.Command {
	return &subcommands.Command{
		Advanced:  true,
		UsageLine: "pkg-register <package instance file>",
		ShortDesc: "uploads and registers package instance in the package repository",
		LongDesc:  "Uploads and registers package instance in the package repository.",
		CommandRun: func() subcommands.CommandRun {
			c := &registerRun{}
			c.registerBaseFlags()
			c.Opts.refsOptions.registerFlags(&c.Flags)
			c.Opts.tagsOptions.registerFlags(&c.Flags)
			c.Opts.clientOptions.registerFlags(&c.Flags, params, withoutRootDir)
			c.Opts.uploadOptions.registerFlags(&c.Flags)
			c.Opts.hashOptions.registerFlags(&c.Flags)
			return c
		},
	}
}
124517
def _attach_subcommands(self):
        
        if self.subcommands:
            self.subparsers = self.parser.add_subparsers()

            for subcommand in self.subcommands:
                subparser = self.subparsers.add_parser(subcommand.name,
                                                       help=subcommand.title)
                if subcommand.handler:
                    self._register_handler(subparser, subcommand.handler)
                subcommand._init(subparser)
830435
private function registerCommand(
        $name, $data, \Console_CommandLine_Command $parent = null)
    {
        $command = isset($data['command']) ? $data['command'] : $data;
        if (null === $parent) {
            $cmd = $this->addCommand($name, $command);
        } else {
            $cmd = $parent->addCommand($name, $command);
        }
        // command arguments
        $args = isset($command['arguments']) ? $command['arguments'] : array();
        foreach ($args as $name => $argument) {
            $cmd->addArgument($name, $argument);
        }
        // command options
        $opts = isset($command['options']) ? $command['options'] : array();
        foreach ($opts as $name => $option) {
            $cmd->addOption($name, $option);
        }
        // commands actions (sub-commands)
        $subs = isset($command['commands']) ? $command['commands'] : array();
        foreach ($subs as $name => $data) {
            $this->registerCommand($name, $data, $cmd);
        }
    }
795822
def subcommand(self, description='', arguments={}):
        '''
        
        '''
        def decorator(func):
            self.register_subparser(
                func,
                func.__name__.replace('_', '-'),
                description=description,
                arguments=arguments,
            )
            return func
        return decorator
700621
function ( pkg ) {
			grunt.verbose.writeln( "Populating compiler" );
			var copts = {
				noParse             : pkg.noParse,
				entries             : pkg.modules,
				externalRequireName : options.externalRequireName,
				pack                : options.pack,
				bundleExternal      : options.bundleExternal,
//				builtins            : options.builtins,
				fullPaths           : options.fullPaths,
				commondir           : options.commondir,
				basedir             : options.basedir,
				extensions          : options.extensions
			}

			if ( !sys.isEmpty( options.builtins ) ) {
				copts.builtins = options.builtins;
			}

			var compiler = browsCompiler( copts );
			sys.each( pkg.exec, function ( item ) {
				compiler.add( item );
			} );

			sys.each( pkg.aliases, function ( item, name ) {

				compiler.require( item, {expose : name} );
			} );

			sys.each( pkg.publish, function ( item ) {
				compiler.require( item );
			} );

			sys.each( pkg.externals, function ( item ) {
				compiler.external( item );
			} );

			sys.each( pkg.ignore, function ( item ) {
				compiler.ignore( item );
			} );

			return compiler;
		}
386565
func (cmd *Command) Register(child *Command) *Command {
	if child == nil {
		debug.Panicf("command `%s` try register a nil command", cmd.Name)
	}
	if !IsValidCommandName(child.Name) {
		debug.Panicf("illegal command name `%s`", cmd.Name)
	}
	if cmd.children == nil {
		cmd.children = []*Command{}
	}
	if child.parent != nil {
		debug.Panicf("command `%s` has been child of `%s`", child.Name, child.parent.Name)
	}
	if cmd.findChild(child.Name) != nil {
		debug.Panicf("repeat register child `%s` for command `%s`", child.Name, cmd.Name)
	}
	if child.Aliases != nil {
		for _, alias := range child.Aliases {
			if cmd.findChild(alias) != nil {
				debug.Panicf("repeat register child `%s` for command `%s`", alias, cmd.Name)
			}
		}
	}
	cmd.children = append(cmd.children, child)
	child.parent = cmd

	return child
}
539029
function registerUnknownCommands (cli, options) {
  cli.on('command:*', async () => {
    const { args, options: commandoptions } = cli

    logger.debug('global_options', options)
    logger.debug('cli_options', commandoptions)
    logger.debug('cli_args', args)

    const [commandName] = args
    const sourceDir = args[1] ? path.resolve(args[1]) : pwd
    const inferredUserDocsDirectory = await inferUserDocsDirectory(pwd)
    logger.developer('inferredUserDocsDirectory', inferredUserDocsDirectory)
    logger.developer('sourceDir', sourceDir)

    if (inferredUserDocsDirectory && sourceDir !== inferredUserDocsDirectory) {
      logUnknownCommand(cli)
      console.log()
      logger.tip(`Did you miss to specify the target docs dir? e.g. ${chalk.cyan(`vuepress ${commandName} [targetDir]`)}.`)
      logger.tip(`A custom command registered by a plugin requires VuePress to locate your site configuration like ${chalk.cyan('vuepress dev')} or ${chalk.cyan('vuepress build')}.`)
      console.log()
      process.exit(1)
    }

    if (!inferredUserDocsDirectory) {
      logUnknownCommand(cli)
      process.exit(1)
    }

    logger.debug('Custom command', chalk.cyan(commandName))
    CLI({
      async beforeParse (subCli) {
        const app = createApp({
          sourceDir: sourceDir,
          ...options,
          ...commandoptions
        })
        await app.process()
        app.pluginAPI.applySyncOption('extendCli', subCli, app)
        console.log()
      },
      async afterParse (subCli) {
        if (!subCli.matchedCommand) {
          logUnknownCommand(subCli)
          console.log()
        }
      }
    })
  })
}
1174009
func (c *Command) Subcommand(name string) *Command {
	for _, sub := range c.Subcommands {
		if sub.Name == name {
			return sub
		}
		for _, a := range sub.Aliases {
			if a == name {
				return sub
			}
		}
	}
	return nil
}
790183
function SetupCLI(execName, packageJson, Commands, args) {
  assert(_.isString(execName), 'execName must be a string.');
  assert(_.isObject(packageJson), 'packageJson must be an object.');
  assert(_.isObject(Commands), 'Command collection must be an object.');
  assert(_.isObject(args), 'Arguments must be an object.');

  // --version or -v triggers npm version check.
  if (args.version || args.v) {
    const progName = packageJson.title || packageJson.name || process.argv[0];
    console.log(`${progName} ${ShowVersion(packageJson)}`);
    return process.exit(0);
  }

  // Remove 'color' flags if present.
  if ('color' in args) {
    delete args.color;
  }

  // The first positional (non-option) argument is the sub-command to run.
  const cmdName = _.first(args._);
  if (!cmdName) {
    console.error(GetCommandList(execName, packageJson, Commands));
    return process.exit(1);
  }
  const cmd = global.COMMAND = Commands[cmdName];
  if (!cmd) {
    console.error(col.fatal(`Unknown command "${col.bold(cmdName)}".`));
    return process.exit(1);
  }

  // Show command-specific help.
  if (args.help || args.h) {
    console.error(GetCommandUsage(execName, packageJson, cmd, args));
    return process.exit(1);
  }

  // Parse command-line parameters
  try {
    args = ParseArguments(cmd, args);
  } catch (e) {
    console.error(col.fatal(e.message));
    return process.exit(1);
  }

  return args;
}
1019778
function setPkgConfig(loader, pkgName, cfg, prependConfig) {
  var pkg;

  // first package is config by reference for fast path, cloned after that
  if (!loader.packages[pkgName]) {
    pkg = loader.packages[pkgName] = cfg;
  }
  else {
    var basePkg = loader.packages[pkgName];
    pkg = loader.packages[pkgName] = {};

    extendPkgConfig(pkg, prependConfig ? cfg : basePkg, pkgName, loader, prependConfig);
    extendPkgConfig(pkg, prependConfig ? basePkg : cfg, pkgName, loader, !prependConfig);
  }
  
  // main object becomes main map
  if (typeof pkg.main == 'object') {
    pkg.map = pkg.map || {};
    pkg.map['./@main'] = pkg.main;
    pkg.main['default'] = pkg.main['default'] || './';
    pkg.main = '@main';
  }

  return pkg;
}
149573
func (c *Commands) Register(cmdstr string, cf cmdfunc, helpMsg string) {
	for _, v := range c.cmds {
		if v.match(cmdstr) {
			v.cmdFn = cf
			return
		}
	}

	c.cmds = append(c.cmds, command{aliases: []string{cmdstr}, cmdFn: cf, helpMsg: helpMsg})
}
834080
def _run_configure(subcmd, args):
    
    maps = {
        "packages": _conf_packages
        }
    if subcmd in maps:
        maps[subcmd](args)
    else:
        msg.warn("'configure' sub-command {} is not supported.".format(subcmd))
4361
func RegisterCommands(app *cobra.Command, c *client.Client) {
	var command, sub *cobra.Command
	command = &cobra.Command{
		Use:   "create",
		Short: `create action`,
	}
	tmp1 := new(CreateAccountCommand)
	sub = &cobra.Command{
		Use:   `account ["/cellar/accounts"]`,
		Short: ``,
		Long: `

Payload example:

{
   "name": "test"
}`,
		RunE: func(cmd *cobra.Command, args []string) error { return tmp1.Run(c, args) },
	}
	tmp1.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp1.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	tmp2 := new(CreateBottleCommand)
	sub = &cobra.Command{
		Use:   `bottle ["/cellar/accounts/ACCOUNTID/bottles"]`,
		Short: ``,
		Long: `

Payload example:

{
   "color": "white",
   "country": "USA",
   "name": "Number 8",
   "region": "Napa Valley",
   "review": "Great and inexpensive",
   "sweetness": 1,
   "varietal": "Merlot",
   "vineyard": "Asti",
   "vintage": 2012
}`,
		RunE: func(cmd *cobra.Command, args []string) error { return tmp2.Run(c, args) },
	}
	tmp2.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp2.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	app.AddCommand(command)
	command = &cobra.Command{
		Use:   "delete",
		Short: `delete action`,
	}
	tmp3 := new(DeleteAccountCommand)
	sub = &cobra.Command{
		Use:   `account ["/cellar/accounts/ACCOUNTID"]`,
		Short: ``,
		RunE:  func(cmd *cobra.Command, args []string) error { return tmp3.Run(c, args) },
	}
	tmp3.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp3.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	tmp4 := new(DeleteBottleCommand)
	sub = &cobra.Command{
		Use:   `bottle ["/cellar/accounts/ACCOUNTID/bottles/BOTTLEID"]`,
		Short: ``,
		RunE:  func(cmd *cobra.Command, args []string) error { return tmp4.Run(c, args) },
	}
	tmp4.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp4.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	app.AddCommand(command)
	command = &cobra.Command{
		Use:   "health",
		Short: `Perform health check.`,
	}
	tmp5 := new(HealthHealthCommand)
	sub = &cobra.Command{
		Use:   `health ["/cellar/_ah/health"]`,
		Short: ``,
		RunE:  func(cmd *cobra.Command, args []string) error { return tmp5.Run(c, args) },
	}
	tmp5.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp5.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	app.AddCommand(command)
	command = &cobra.Command{
		Use:   "list",
		Short: `list action`,
	}
	tmp6 := new(ListAccountCommand)
	sub = &cobra.Command{
		Use:   `account ["/cellar/accounts"]`,
		Short: ``,
		RunE:  func(cmd *cobra.Command, args []string) error { return tmp6.Run(c, args) },
	}
	tmp6.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp6.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	tmp7 := new(ListBottleCommand)
	sub = &cobra.Command{
		Use:   `bottle ["/cellar/accounts/ACCOUNTID/bottles"]`,
		Short: ``,
		RunE:  func(cmd *cobra.Command, args []string) error { return tmp7.Run(c, args) },
	}
	tmp7.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp7.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	app.AddCommand(command)
	command = &cobra.Command{
		Use:   "rate",
		Short: ``,
	}
	tmp8 := new(RateBottleCommand)
	sub = &cobra.Command{
		Use:   `bottle ["/cellar/accounts/ACCOUNTID/bottles/BOTTLEID/actions/rate"]`,
		Short: ``,
		Long: `

Payload example:

{
   "rating": 3
}`,
		RunE: func(cmd *cobra.Command, args []string) error { return tmp8.Run(c, args) },
	}
	tmp8.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp8.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	app.AddCommand(command)
	command = &cobra.Command{
		Use:   "show",
		Short: `show action`,
	}
	tmp9 := new(ShowAccountCommand)
	sub = &cobra.Command{
		Use:   `account ["/cellar/accounts/ACCOUNTID"]`,
		Short: ``,
		RunE:  func(cmd *cobra.Command, args []string) error { return tmp9.Run(c, args) },
	}
	tmp9.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp9.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	tmp10 := new(ShowBottleCommand)
	sub = &cobra.Command{
		Use:   `bottle ["/cellar/accounts/ACCOUNTID/bottles/BOTTLEID"]`,
		Short: ``,
		RunE:  func(cmd *cobra.Command, args []string) error { return tmp10.Run(c, args) },
	}
	tmp10.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp10.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	app.AddCommand(command)
	command = &cobra.Command{
		Use:   "update",
		Short: `update action`,
	}
	tmp11 := new(UpdateAccountCommand)
	sub = &cobra.Command{
		Use:   `account ["/cellar/accounts/ACCOUNTID"]`,
		Short: ``,
		Long: `

Payload example:

{
   "name": "test"
}`,
		RunE: func(cmd *cobra.Command, args []string) error { return tmp11.Run(c, args) },
	}
	tmp11.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp11.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	tmp12 := new(UpdateBottleCommand)
	sub = &cobra.Command{
		Use:   `bottle ["/cellar/accounts/ACCOUNTID/bottles/BOTTLEID"]`,
		Short: ``,
		Long: `

Payload example:

{
   "color": "white",
   "country": "USA",
   "name": "Number 8",
   "region": "Napa Valley",
   "review": "Great and inexpensive",
   "sweetness": 1,
   "varietal": "Merlot",
   "vineyard": "Asti",
   "vintage": 2012
}`,
		RunE: func(cmd *cobra.Command, args []string) error { return tmp12.Run(c, args) },
	}
	tmp12.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp12.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	app.AddCommand(command)
	command = &cobra.Command{
		Use:   "watch",
		Short: `Retrieve bottle with given id`,
	}
	tmp13 := new(WatchBottleCommand)
	sub = &cobra.Command{
		Use:   `bottle ["/cellar/accounts/ACCOUNTID/bottles/BOTTLEID/watch"]`,
		Short: ``,
		RunE:  func(cmd *cobra.Command, args []string) error { return tmp13.Run(c, args) },
	}
	tmp13.RegisterFlags(sub, c)
	sub.PersistentFlags().BoolVar(&tmp13.PrettyPrint, "pp", false, "Pretty print response body")
	command.AddCommand(sub)
	app.AddCommand(command)

	dl := new(DownloadCommand)
	dlc := &cobra.Command{
		Use:   "download [PATH]",
		Short: "Download file with given path",
		RunE: func(cmd *cobra.Command, args []string) error {
			return dl.Run(c, args)
		},
	}
	dlc.Flags().StringVar(&dl.OutFile, "out", "", "Output file")
	app.AddCommand(dlc)
}
949824
def register(cls, parser, name=None):
        
        help_title, help_body = utils.parse_docstring(cls)
        command_parser = parser.subparsers.add_parser(
            cls.name() if name is None else name, help=help_title,
            description=help_title, epilog=help_body, add_help=False,
            formatter_class=HelpFormatter)
        command_parser.add_argument(
            "-h", "--help", action=PagedHelpAction, help=argparse.SUPPRESS)
        command_parser.set_defaults(execute=cls(command_parser))
        return command_parser
1286027
function pkgdir() {
	var parts,
		len,
		str,
		i;

	parts = cwd().split( path.sep );
	len = parts.length;
	for ( i = 0; i < len; i++ ) {
		str = parts.join( path.sep );
		if ( exists( path.join( str, 'package.json' ) ) ) {
			return str;
		}
		parts.pop();
	}
	return null;
}
582009
def _lockcmd(subcmd, pkgname=None, **kwargs):
    '''
    
    '''

    jail = kwargs.pop('jail', None)
    chroot = kwargs.pop('chroot', None)
    root = kwargs.pop('root', None)

    locked_pkgs = []

    cmd = _pkg(jail, chroot, root)
    cmd.append(subcmd)
    cmd.append('-y')
    cmd.append('--quiet')
    cmd.append('--show-locked')

    if pkgname:
        cmd.append(pkgname)

    out = __salt__['cmd.run_all'](cmd, output_loglevel='trace', python_shell=False)

    if out['retcode'] != 0:
        raise CommandExecutionError(
            'Problem encountered {0}ing packages'.format(subcmd),
            info={'result': out}
        )

    for line in salt.utils.itertools.split(out['stdout'], '\n'):
        if not line:
            continue
        try:
            pkgname = line.rsplit('-', 1)[0]
        except ValueError:
            continue
        locked_pkgs.append(pkgname)

    log.debug('Locked packages: %s', ', '.join(locked_pkgs))
    return locked_pkgs
538074
func (c *CLI) SubcommandArgs() []string {
	c.once.Do(c.init)
	return c.subcommandArgs
}