Example #1
0
def _get_plugin_parser():
    """Sets up the plugin arg parser and all of its subcommand parsers."""

    top_parser = ArgumentParser()
    subparsers = top_parser.add_subparsers(title='commands')

    parser = subparsers.add_parser('list', help="List installed plugins")
    parser.usage = "plugin list [options]"
    parser.add_argument("--github",
                        help='List plugins in the official Openmdao-Plugins'
                        ' repository on github',
                        action='store_true')
    parser.add_argument("-b",
                        "--builtin",
                        help='List all installed plugins that are part of the'
                        ' OpenMDAO distribution',
                        action='store_true')
    parser.add_argument("-e",
                        "--external",
                        help='List all installed plugins that are not part of'
                        ' the OpenMDAO distribution',
                        action='store_true')
    parser.add_argument(
        "-g",
        "--group",
        action="append",
        type=str,
        dest='groups',
        default=[],
        choices=[p.split('.', 1)[1] for p in plugin_groups.keys()],
        help="specify plugin group")
    parser.set_defaults(func=plugin_list)

    parser = subparsers.add_parser('install',
                                   help="install an OpenMDAO plugin into the"
                                   " current environment")
    parser.usage = "plugin install [plugin_distribution] [options]"
    parser.add_argument('dist_name',
                        help='name of plugin distribution'
                        ' (defaults to distrib found in current dir)',
                        nargs='?')
    parser.add_argument("--github",
                        help='Find plugin in the official OpenMDAO-Plugins'
                        ' repository on github',
                        action='store_true')
    parser.add_argument("-f",
                        "--find-links",
                        action="store",
                        type=str,
                        dest='findlinks',
                        default='http://openmdao.org/dists',
                        help="URL of find-links server")
    parser.add_argument(
        "--all",
        help='Install all plugins in the official OpenMDAO-Plugins'
        ' repository on github',
        action='store_true')
    parser.set_defaults(func=plugin_install)

    parser = subparsers.add_parser('build_docs',
                                   help="build sphinx doc files for a plugin")
    parser.usage = "plugin build_docs <dist_dir_path>"
    parser.add_argument('dist_dir_path',
                        help='path to distribution source directory')
    parser.set_defaults(func=plugin_build_docs)

    parser = subparsers.add_parser('docs', help="display docs for a plugin")
    parser.usage = "plugin docs <plugin_dist_name>"
    parser.add_argument('plugin_dist_name', help='name of plugin distribution')
    parser.add_argument("-b",
                        "--browser",
                        action="store",
                        type=str,
                        dest='browser',
                        choices=webbrowser._browsers.keys(),
                        help="browser name")
    parser.set_defaults(func=plugin_docs)

    parser = subparsers.add_parser(
        'quickstart', help="generate some skeleton files for a plugin")
    parser.usage = "plugin quickstart <dist_name> [options]"
    parser.add_argument('dist_name', help='name of distribution')
    parser.add_argument("-v",
                        "--version",
                        action="store",
                        type=str,
                        dest='version',
                        default='0.1',
                        help="version id of the plugin (defaults to 0.1)")
    parser.add_argument("-c",
                        "--class",
                        action="store",
                        type=str,
                        dest='classname',
                        help="plugin class name")
    parser.add_argument("-d",
                        "--dest",
                        action="store",
                        type=str,
                        dest='dest',
                        default='.',
                        help="directory where new plugin directory will be"
                        " created (defaults to current dir)")
    parser.add_argument("-g",
                        "--group",
                        action="store",
                        type=str,
                        dest='group',
                        default='openmdao.component',
                        help="specify plugin group %s (defaults to"
                        " 'openmdao.component')" % plugin_groups.keys())
    parser.set_defaults(func=plugin_quickstart)

    parser = subparsers.add_parser(
        'makedist', help="create a source distribution for a plugin")
    parser.usage = "plugin makedist [dist_dir_path]"
    parser.add_argument('dist_dir_path',
                        nargs='?',
                        default='.',
                        help='directory where plugin distribution is found'
                        ' (defaults to current dir')
    parser.set_defaults(func=plugin_makedist)

    return top_parser
Example #2
0
def _get_plugin_parser():
    """Sets up the plugin arg parser and all of its subcommand parsers."""
    
    top_parser = ArgumentParser()
    subparsers = top_parser.add_subparsers(title='commands')
    
    parser = subparsers.add_parser('list', help = "List installed plugins")
    parser.usage = "plugin list [options]"
    parser.add_argument("--github", 
                        help='List plugins in the official Openmdao-Plugins'
                             ' repository on github', 
                        action='store_true')
    parser.add_argument("-b", "--builtin", 
                        help='List all installed plugins that are part of the'
                             ' OpenMDAO distribution', 
                        action='store_true')
    parser.add_argument("-e", "--external", 
                        help='List all installed plugins that are not part of'
                             ' the OpenMDAO distribution', 
                        action='store_true')
    parser.add_argument("-g", "--group", action="append", type=str,
                        dest='groups', default=[], 
                        choices=[p.split('.',1)[1] for p in plugin_groups.keys()],
                        help="specify plugin group")
    parser.set_defaults(func=plugin_list)
    
    
    parser = subparsers.add_parser('install', 
                                   help="install an OpenMDAO plugin into the"
                                        " current environment")
    parser.usage = "plugin install [plugin_distribution] [options]"
    parser.add_argument('dist_name',
                        help='name of plugin distribution'
                             ' (defaults to distrib found in current dir)', 
                        nargs='?')
    parser.add_argument("--github", 
                        help='Find plugin in the official OpenMDAO-Plugins'
                             ' repository on github', 
                        action='store_true')
    parser.add_argument("-f", "--find-links", action="store", type=str, 
                        dest='findlinks', default='http://openmdao.org/dists',
                        help="URL of find-links server")
    parser.add_argument("--all", help='Install all plugins in the official OpenMDAO-Plugins'
                        ' repository on github', action='store_true')
    parser.set_defaults(func=plugin_install)
    
    
    parser = subparsers.add_parser('build_docs', 
                                   help="build sphinx doc files for a plugin")
    parser.usage = "plugin build_docs <dist_dir_path>"
    parser.add_argument('dist_dir_path',
                        help='path to distribution source directory')
    parser.set_defaults(func=plugin_build_docs)

    
    parser = subparsers.add_parser('docs', 
                                   help="display docs for a plugin")
    parser.usage = "plugin docs <plugin_dist_name>"
    parser.add_argument('plugin_dist_name', help='name of plugin distribution')
    parser.add_argument("-b", "--browser", action="store", type=str, 
                        dest='browser', choices=webbrowser._browsers.keys(),
                        help="browser name")
    parser.set_defaults(func=plugin_docs)
    
    
    parser = subparsers.add_parser('quickstart',
                                   help="generate some skeleton files for a plugin")
    parser.usage = "plugin quickstart <dist_name> [options]"
    parser.add_argument('dist_name', help='name of distribution')
    parser.add_argument("-v", "--version", action="store", type=str,
                        dest='version', default='0.1',
                        help="version id of the plugin (defaults to 0.1)")
    parser.add_argument("-c", "--class", action="store", type=str,
                        dest='classname', help="plugin class name")
    parser.add_argument("-d", "--dest", action="store", type=str, dest='dest', 
                        default='.',
                        help="directory where new plugin directory will be"
                             " created (defaults to current dir)")
    parser.add_argument("-g", "--group", action="store", type=str, dest='group',
                        default = 'openmdao.component',
                        help="specify plugin group %s (defaults to"
                             " 'openmdao.component')" % plugin_groups.keys())
    parser.set_defaults(func=plugin_quickstart)
    
    
    parser = subparsers.add_parser('makedist',
                                   help="create a source distribution for a plugin")
    parser.usage = "plugin makedist [dist_dir_path]"
    parser.add_argument('dist_dir_path', nargs='?',
                        default='.',
                        help='directory where plugin distribution is found'
                             ' (defaults to current dir')
    parser.set_defaults(func=plugin_makedist)
    
    return top_parser
Example #3
0
def _get_plugin_parser():
    """Sets up the plugin arg parser and all of its subcommand parsers."""

    top_parser = ArgumentParser()
    subparsers = top_parser.add_subparsers(title='commands')

    parser = subparsers.add_parser('list',
                        help="List installed plugins, or list plugins " \
                             "available on github.")

    parser.usage = "plugin list [options]"
    parser.add_argument("--github",
                        help='List plugin repos owned by OWNER on github.',
                        action='store',
                        nargs='?',
                        type=str,
                        dest='owner',
                        const='OpenMDAO-Plugins')

    parser.add_argument("-b",
                        "--builtin",
                        help='List all installed plugins that are part of the'
                        ' OpenMDAO distribution',
                        action='store_true')

    parser.add_argument("-e",
                        "--external",
                        help='List all installed plugins that are not part of'
                        ' the OpenMDAO distribution',
                        action='store_true')

    parser.add_argument(
        "-g",
        "--group",
        action="append",
        type=str,
        dest='groups',
        default=[],
        choices=[p.split('.', 1)[1] for p in plugin_groups.keys()],
        help="List plugins of a specified type. "
        "Type should be one of the listed options.")

    parser.set_defaults(func=plugin_list)

    parser = subparsers.add_parser(
        'install',
        help="install an OpenMDAO plugin into the"
        " current environment",
        description=
        "Install selected plugin or plugins either locally or from github.",
        formatter_class=RawDescriptionHelpFormatter)

    parser.usage = "plugin install [dist_name] [options] \n"

    parser.epilog = "example: get the plugin pyopt_driver from github \n" \
                    ">plugin install pyopt_driver --github\n\n" \
                    "example: install all OpenMDAO-compatible plugins from GithubMember's repo.\n" \
                    ">plugin install --github GithubMember --all"

    #can't do a single component and --all in same command, make them m.e.
    group = parser.add_mutually_exclusive_group()

    group.add_argument(
        'dist_name',
        help='name of a single plugin distribution.  cannot be used with --all.'
        '(defaults to distrib found in current dir)',
        nargs='?')

    parser.add_argument(
        "--github",
        action='store',
        nargs='?',
        type=str,
        dest='owner',
        const='OpenMDAO-Plugins',
        help='Search for plugin repo owned by OWNER on github. '
        'Defaults to \'OpenMDAO-Plugins\'')

    parser.add_argument("-f",
                        "--find-links",
                        action="store",
                        type=str,
                        dest='findlinks',
                        default='http://openmdao.org/dists',
                        help="URL of find-links server. Defaults to "
                        "'http://openmdao.org/dists'")

    group.add_argument("--all",
                       help='Install all plugins owned by OWNER as specified '
                       'with --github.  Defaults to OpenMDAO-Plugins.',
                       action='store_true')

    parser.set_defaults(func=plugin_install)

    parser = subparsers.add_parser('build_docs',
                                   help="build sphinx doc files for a plugin")
    parser.usage = "plugin build_docs <dist_dir_path>"
    parser.add_argument('dist_dir_path',
                        default='.',
                        help='path to distribution source directory')
    parser.add_argument("-s",
                        "--srcdir",
                        action="store",
                        type=str,
                        dest='srcdir',
                        default='src',
                        help="top directory in the distribution where python"
                        " source is located")
    parser.set_defaults(func=plugin_build_docs)

    parser = subparsers.add_parser('docs', help="display docs for a plugin")
    parser.usage = "plugin docs <plugin_dist_name>"

    parser.add_argument('plugin_dist_name', help='name of plugin distribution')
    parser.add_argument("-b",
                        "--browser",
                        action="store",
                        type=str,
                        dest='browser',
                        choices=webbrowser._browsers.keys(),
                        help="browser name")
    parser.set_defaults(func=plugin_docs)

    parser = subparsers.add_parser('quickstart',
                                   help="generate some skeleton"
                                   " files for a plugin")
    parser.usage = "plugin quickstart <dist_name> [options]"
    parser.add_argument('dist_name', help='name of distribution')
    parser.add_argument("-v",
                        "--version",
                        action="store",
                        type=str,
                        dest='version',
                        default='0.1',
                        help="version id of the plugin (defaults to 0.1)")
    parser.add_argument("-c",
                        "--class",
                        action="store",
                        type=str,
                        dest='classname',
                        help="plugin class name")
    parser.add_argument("-d",
                        "--dest",
                        action="store",
                        type=str,
                        dest='dest',
                        default='.',
                        help="directory where new plugin directory will be"
                        " created (defaults to current dir)")
    parser.add_argument("-g",
                        "--group",
                        action="store",
                        type=str,
                        dest='group',
                        default='openmdao.component',
                        help="specify plugin group %s (defaults to"
                        " 'openmdao.component')" % plugin_groups.keys())
    parser.set_defaults(func=plugin_quickstart)

    parser = subparsers.add_parser('makedist',
                                   help="create a source"
                                   " distribution for a plugin")
    parser.usage = "plugin makedist [dist_dir_path]"
    parser.add_argument('dist_dir_path',
                        nargs='?',
                        default='.',
                        help='directory where plugin distribution is found'
                        ' (defaults to current dir')
    parser.add_argument("-s",
                        "--srcdir",
                        action="store",
                        type=str,
                        dest='srcdir',
                        default='src',
                        help="top directory in the distribution where python"
                        " source is located")
    parser.set_defaults(func=plugin_makedist)

    return top_parser
Example #4
0
def _get_plugin_parser():
    """Sets up the plugin arg parser and all of its subcommand parsers."""

    top_parser = ArgumentParser()
    subparsers = top_parser.add_subparsers(title="commands")

    parser = subparsers.add_parser("list", help="List installed plugins")
    parser.usage = "plugin list [options]"
    parser.add_argument(
        "--github", help="List plugins in the official Openmdao-Plugins repository on github", action="store_true"
    )
    parser.add_argument(
        "-b",
        "--builtin",
        help="List all installed plugins that are part of the OpenMDAO distribution",
        action="store_true",
    )
    parser.add_argument(
        "-e",
        "--external",
        help="List all installed plugins that are not part of the OpenMDAO distribution",
        action="store_true",
    )
    parser.add_argument(
        "-g",
        "--group",
        action="append",
        type=str,
        dest="groups",
        default=[],
        choices=[p.split(".", 1)[1] for p in plugin_groups.keys()],
        help="specify plugin group",
    )
    parser.set_defaults(func=plugin_list)

    parser = subparsers.add_parser("install", help="install an OpenMDAO plugin into the current environment")
    parser.usage = "plugin install [plugin_distribution] [options]"
    parser.add_argument(
        "dist_name", help="name of plugin distribution (defaults to distrib found in current dir)", nargs="?"
    )
    parser.add_argument(
        "--github", help="Find plugin in the official Openmdao-Plugins repository on github", action="store_true"
    )
    parser.add_argument(
        "-f",
        "--find-links",
        action="store",
        type=str,
        dest="findlinks",
        default="http://openmdao.org/dists",
        help="URL of find-links server",
    )
    parser.set_defaults(func=plugin_install)

    parser = subparsers.add_parser("build_docs", help="build sphinx doc files for a plugin")
    parser.usage = "plugin build_docs <dist_dir_path>"
    parser.add_argument("dist_dir_path", help="path to distribution source directory")
    parser.set_defaults(func=plugin_build_docs)

    parser = subparsers.add_parser("docs", help="display docs for a plugin")
    parser.usage = "plugin docs <plugin_dist_name>"
    parser.add_argument("plugin_dist_name", help="name of plugin distribution")
    parser.add_argument(
        "-b",
        "--browser",
        action="store",
        type=str,
        dest="browser",
        choices=webbrowser._browsers.keys(),
        help="browser name",
    )
    parser.set_defaults(func=plugin_docs)

    parser = subparsers.add_parser("quickstart", help="generate some skeleton files for a plugin")
    parser.usage = "plugin quickstart <dist_name> [options]"
    parser.add_argument("dist_name", help="name of distribution")
    parser.add_argument(
        "-v",
        "--version",
        action="store",
        type=str,
        dest="version",
        default="0.1",
        help="version id of the plugin (defaults to 0.1)",
    )
    parser.add_argument("-c", "--class", action="store", type=str, dest="classname", help="plugin class name")
    parser.add_argument(
        "-d",
        "--dest",
        action="store",
        type=str,
        dest="dest",
        default=".",
        help="directory where new plugin directory will be created (defaults to current dir)",
    )
    parser.add_argument(
        "-g",
        "--group",
        action="store",
        type=str,
        dest="group",
        default="openmdao.component",
        help="specify plugin group %s (defaults to 'openmdao.component')" % plugin_groups.keys(),
    )
    parser.set_defaults(func=plugin_quickstart)

    parser = subparsers.add_parser("makedist", help="create a source distribution for a plugin")
    parser.usage = "plugin makedist [dist_dir_path]"
    parser.add_argument(
        "dist_dir_path",
        nargs="?",
        default=".",
        help="directory where plugin distribution is found (defaults to current dir",
    )
    parser.set_defaults(func=plugin_makedist)

    return top_parser
def _get_plugin_parser():
    """Sets up the plugin arg parser and all of its subcommand parsers."""

    top_parser = ArgumentParser()
    subparsers = top_parser.add_subparsers(title='commands')

    parser = subparsers.add_parser('list',
                        help="List installed plugins, or list plugins " \
                             "available on github.")

    parser.usage = "plugin list [options]"
    parser.add_argument("--github",
                        help='List plugin repos owned by OWNER on github.',
                        action='store',
                        nargs='?',
                        type=str,
                        dest='owner',
                        const='OpenMDAO-Plugins')

    parser.add_argument("-b", "--builtin",
                        help='List all installed plugins that are part of the'
                             ' OpenMDAO distribution',
                        action='store_true')

    parser.add_argument("-e", "--external",
                        help='List all installed plugins that are not part of'
                             ' the OpenMDAO distribution',
                        action='store_true')

    parser.add_argument("-g", "--group",
                        action="append",
                        type=str,
                        dest='groups',
                        default=[],
                        choices=[p.split('.', 1)[1]
                                 for p in plugin_groups.keys()],
                        help="List plugins of a specified type. "
                             "Type should be one of the listed options.")

    parser.set_defaults(func=plugin_list)

    parser = subparsers.add_parser('install',
                                   help="install an OpenMDAO plugin into the"
                                        " current environment",
                                   description="Install selected plugin or plugins either locally or from github.",
                                   formatter_class=RawDescriptionHelpFormatter)

    parser.usage = "plugin install [dist_name] [options] \n"

    parser.epilog = "example: get the plugin pyopt_driver from github \n" \
                    ">plugin install pyopt_driver --github\n\n" \
                    "example: install all OpenMDAO-compatible plugins from GithubMember's repo.\n" \
                    ">plugin install --github GithubMember --all" 

    #can't do a single component and --all in same command, make them m.e.
    group = parser.add_mutually_exclusive_group()

    group.add_argument('dist_name',
                        help='name of a single plugin distribution.  cannot be used with --all.'
                             '(defaults to distrib found in current dir)',
                        nargs='?')

    parser.add_argument("--github", action='store',  nargs='?', type=str, dest='owner',
                        const='OpenMDAO-Plugins',
                        help='Search for plugin repo owned by OWNER on github. '
                             'Defaults to \'OpenMDAO-Plugins\'' )

    parser.add_argument("-f", "--find-links", action="store", type=str,
                        dest='findlinks', default='http://openmdao.org/dists',
                        help="URL of find-links server. Defaults to "
                             "'http://openmdao.org/dists'")

    group.add_argument("--all",
                        help='Install all plugins owned by OWNER as specified '
                             'with --github.  Defaults to OpenMDAO-Plugins.',
                        action='store_true')

    parser.set_defaults(func=plugin_install)

    parser = subparsers.add_parser('build_docs',
                                   help="build sphinx doc files for a plugin")
    parser.usage = "plugin build_docs <dist_dir_path>"
    parser.add_argument('dist_dir_path', default='.',
                        help='path to distribution source directory')
    parser.add_argument("-s", "--srcdir", action="store", type=str,
                        dest='srcdir', default='src',
                        help="top directory in the distribution where python"
                             " source is located")
    parser.set_defaults(func=plugin_build_docs)

    parser = subparsers.add_parser('docs',
                                   help="display docs for a plugin")
    parser.usage = "plugin docs <plugin_dist_name>"

    parser.add_argument('plugin_dist_name', help='name of plugin distribution')
    parser.add_argument("-b", "--browser", action="store", type=str,
                        dest='browser', choices=webbrowser._browsers.keys(),
                        help="browser name")
    parser.set_defaults(func=plugin_docs)

    parser = subparsers.add_parser('quickstart', help="generate some skeleton"
                                                      " files for a plugin")
    parser.usage = "plugin quickstart <dist_name> [options]"
    parser.add_argument('dist_name', help='name of distribution')
    parser.add_argument("-v", "--version", action="store", type=str,
                        dest='version', default='0.1',
                        help="version id of the plugin (defaults to 0.1)")
    parser.add_argument("-c", "--class", action="store", type=str,
                        dest='classname', help="plugin class name")
    parser.add_argument("-d", "--dest", action="store", type=str, dest='dest',
                        default='.',
                        help="directory where new plugin directory will be"
                             " created (defaults to current dir)")
    parser.add_argument("-g", "--group", action="store", type=str, dest='group',
                        default='openmdao.component',
                        help="specify plugin group %s (defaults to"
                             " 'openmdao.component')" % plugin_groups.keys())
    parser.set_defaults(func=plugin_quickstart)

    parser = subparsers.add_parser('makedist', help="create a source"
                                                   " distribution for a plugin")
    parser.usage = "plugin makedist [dist_dir_path]"
    parser.add_argument('dist_dir_path', nargs='?',
                        default='.',
                        help='directory where plugin distribution is found'
                             ' (defaults to current dir')
    parser.add_argument("-s", "--srcdir", action="store", type=str,
                        dest='srcdir', default='src',
                        help="top directory in the distribution where python"
                             " source is located")
    parser.set_defaults(func=plugin_makedist)

    return top_parser