def _get_cmd(prepare=False): cmd = Command(name='pocket_protector', func=None, doc=__doc__) # func=None means output help # add flags cmd.add('--file', missing='protected.yaml', doc='path to the PocketProtector-managed file, defaults to protected.yaml in the working directory') cmd.add('--confirm', parse_as=True, doc='show diff and prompt for confirmation before modifying the file') cmd.add('--non-interactive', parse_as=True, doc='disable falling back to interactive authentication, useful for automation') cmd.add('--ignore-env', parse_as=True, display=False, # TODO: keep? doc='ignore environment variables like PPROTECT_PASSPHRASE') cmd.add('--user', char='-u', doc="the acting user's email credential") cmd.add('--passphrase-file', doc='path to a file containing only the passphrase, likely provided by a deployment system') # add middlewares, outermost first ("first added, first called") cmd.add(mw_verify_creds) cmd.add(mw_write_kf) cmd.add(mw_ensure_kf) cmd.add(mw_exit_handler) # add subcommands cmd.add(add_key_custodian, name='init', doc='create a new protected') cmd.add(add_key_custodian) cmd.add(add_domain) cmd.add(rm_domain) cmd.add(add_owner) cmd.add(rm_owner) cmd.add(add_secret) cmd.add(update_secret) cmd.add(rm_secret) cmd.add(set_key_custodian_passphrase) cmd.add(rotate_domain_keys) cmd.add(decrypt_domain, posargs={'count': 1, 'provides': 'domain_name'}) cmd.add(list_domains) cmd.add(list_domain_secrets, posargs={'count': 1, 'provides': 'domain_name'}) cmd.add(list_all_secrets) cmd.add(list_audit_log) cmd.add(print_version, name='version') if prepare: cmd.prepare() # an optional check on all subcommands, not just the one being executed return cmd
def main(argv=None): """\ automation and analytics for curated lists of awesome software. Normal analysis workflow: * apatite pull-repos (can take 3-4 hours, 25GB on the full APA, use --targets to limit) * apatite collect-metrics * apatite export-metrics * apatite analyze # TODO """ cmd = Command(name='apatite', func=None, doc=main.__doc__) # func=None means output help # add flags cmd.add('--file', missing='projects.yaml', doc='path to the project listing YAML file') cmd.add( '--confirm', parse_as=True, doc='show diff and prompt for confirmation before modifying the file') cmd.add( '--non-interactive', parse_as=True, doc= 'disable falling back to interactive authentication, useful for automation' ) cmd.add('--targets', parse_as=ListParam(str), missing=[], doc='specific target projects') cmd.add('--metrics', parse_as=ListParam(str), missing=[], doc='specific metrics to collect') cmd.add('--dry-run', parse_as=True, doc='do not save results') two_weeks_ago = _date_param('-2w') cmd.add( '--earliest', parse_as=_date_param, missing=two_weeks_ago, doc=( 'minimum datetime value to accept (isodate or negative timedelta).' ' defaults to two weeks ago (-2w)')) cmd.add('--no-progress', parse_as=True) # add middlewares, outermost first ("first added, first called") cmd.add(mw_exit_handler) cmd.add(mw_ensure_project_listing) cmd.add(mw_ensure_work_dir) # add subcommands cmd.add(render) cmd.add(normalize) cmd.add(pull_repos) cmd.add(collect_metrics) cmd.add(show_recent_metrics) cmd.add(export_metrics) cmd.add(show_exportable_metrics) cmd.add(set_repo_added_dates) cmd.add(console) cmd.add(print_version, name='version') cmd.prepare( ) # an optional check on all subcommands, not just the one being executed try: cmd.run(argv=argv) # exit behavior is handled by mw_exit_handler except Exception: if os.getenv('APATITE_DEBUG'): import pdb pdb.post_mortem() raise return
def main(): """ The main entrypoint, setting up a face application, with middleware, common flags, and subcommands. """ cmd = Command(name='montage-admin', func=None, doc="CLI tools for administrating Montage.") # middleware cmd.add(_admin_dao_mw) cmd.add(_rdb_session_mw) cmd.add('--username', missing=ERROR) cmd.add('--debug', parse_as=True, doc='get extra output, enable debug console before db commit') cmd.add('--force', parse_as=True, doc='skip some confirmations, use with caution') cmd.add('--campaign-id', parse_as=int, missing=ERROR) cmd.add('--round-id', parse_as=int, missing=ERROR) cmd.add('--csv-path', missing=ERROR) cmd.add('--url', missing=ERROR) cmd.add( add_organizer ) # , posargs={'count': 1, 'name': 'username'}) # TODO: figure out if we want posarg/flag overriding ser_cmd = Command(name='series', func=None, doc='tools for administrating Montage series') ser_cmd.add(add_series, name='add') cmd.add(ser_cmd) cmp_cmd = Command(name='campaign', func=None, doc='tools for administrating Montage campaigns') cmp_cmd.add(list_campaigns, name='list') cmp_cmd.add(create_campaign, name='create') cmp_cmd.add(add_coordinator, name='add-coordinator') cmp_cmd.add(cancel_campaign, name='cancel') cmp_cmd.add(backfill_series) cmd.add(cmp_cmd) rnd_cmd = Command(name='round', func=None, doc='tools for administrating Montage rounds') rnd_cmd.add(create_round, name='create') rnd_cmd.add(import_gist, name='import-gist') rnd_cmd.add(activate_round, name='activate') rnd_cmd.add(pause_round, name='pause') rnd_cmd.add(advance_round, name='advance') rnd_cmd.add(edit_round_quorum, name='edit-quorum') rnd_cmd.add(check_round_dupes, name='check-dupes') rnd_cmd.add(apply_round_ratings, name='apply-ratings') rnd_cmd.add(retask_duplicate_ratings, name='retask-dupes') rnd_cmd.add(shuffle_round_assignments, name='shuffle-tasks') rnd_cmd.add(cancel_round, name='cancel') cmd.add(rnd_cmd) cmd.add(rdb_console) cmd.prepare() return cmd.run()