def run(args, project_options): # noqa lifecycle_command = _get_lifecycle_command(args) argless_command = _get_command_from_arg(args) if lifecycle_command: lifecycle.execute(lifecycle_command, project_options, args['<part>']) elif argless_command: argless_command() elif args['clean']: _run_clean(args, project_options) elif args['cleanbuild']: lifecycle.cleanbuild(project_options, remote=args['--remote']), elif _is_store_command(args): _run_store_command(args) elif args['tour']: _scaffold_examples(args['<directory>'] or _SNAPCRAFT_TOUR_DIR) elif args['help']: snapcraft.topic_help(args['<topic>'] or args['<plugin>'], args['--devel'], args['topics']) elif args['enable-ci']: enable_ci(args['<ci-system>'], args['--refresh']) elif args['update']: parts.update() elif args['define']: parts.define(args['<part-name>']) elif args['search']: parts.search(' '.join(args['<query>'])) else: # snap by default: lifecycle.snap(project_options, args['<directory>'], args['--output']) return project_options
def run(args, project_options): # noqa lifecycle_command = _get_lifecycle_command(args) argless_command = _get_command_from_arg(args) if lifecycle_command: lifecycle.execute( lifecycle_command, project_options, args['<part>']) elif argless_command: argless_command() elif args['clean']: _run_clean(args, project_options) elif args['cleanbuild']: lifecycle.cleanbuild(project_options), elif _is_store_command(args): _run_store_command(args) elif args['tour']: _scaffold_examples(args['<directory>'] or _SNAPCRAFT_TOUR_DIR) elif args['help']: snapcraft.topic_help(args['<topic>'] or args['<plugin>'], args['--devel'], args['topics']) elif args['update']: parts.update() elif args['define']: parts.define(args['<part-name>']) elif args['search']: parts.search(' '.join(args['<query>'])) else: # snap by default: lifecycle.snap(project_options, args['<directory>'], args['--output']) return project_options
def test_defining_a_part_that_doesnt_exist_helps_out(self): with self.assertRaises(RuntimeError) as raised: parts.define('curler') self.assertEqual( str(raised.exception), 'Cannot find the part name {!r} in the cache. Please consider ' 'going to https://wiki.ubuntu.com/snapcraft/parts to add it.')
def define(ctx, part): """Shows the definition for the cloud part. \b Examples: snapcraft define my-part1 """ try: parts.define(part) except RuntimeError as e: echo.error(e) sys.exit(1)
def run(args, project_options): # noqa lifecycle_command = _get_lifecycle_command(args) argless_command = _get_command_from_arg(args) if lifecycle_command: if _is_containerbuild(): lifecycle.containerbuild(lifecycle_command, project_options, args['<part>']) else: lifecycle.execute( lifecycle_command, project_options, args['<part>']) elif argless_command: argless_command() elif args['clean']: if _is_containerbuild(): step = args['--step'] or 'pull' lifecycle.containerbuild('clean', project_options, args=['--step', step] + args['<part>']) else: _run_clean(args, project_options) elif args['cleanbuild']: lifecycle.cleanbuild(project_options, remote=args['--remote']), elif _is_store_command(args): _run_store_command(args) elif args['tour']: _scaffold_examples(args['<directory>'] or _SNAPCRAFT_TOUR_DIR) elif args['help']: snapcraft.topic_help(args['<topic>'] or args['<plugin>'], args['--devel'], args['topics']) elif args['enable-ci']: enable_ci(args['<ci-system>'], args['--refresh']) elif args['update']: if _is_containerbuild(): lifecycle.containerbuild('update', project_options) else: parts.update() elif args['define']: if _is_containerbuild(): lifecycle.containerbuild('update', project_options, args=args['<part-name>']) else: parts.define(args['<part-name>']) elif args['search']: if _is_containerbuild(): lifecycle.containerbuild('search', project_options, args=' '.join(args['<query>'])) else: parts.search(' '.join(args['<query>'])) else: # snap by default: if _is_containerbuild(): lifecycle.containerbuild('snap', project_options, args['--output'], args['<directory>']) elif os.getenv('SNAPCRAFT_COLLABORATE'): # this is only for testing snapcraft.collaborate( os.getenv('SNAPCRAFT_COLLABORATORS_SNAP_NAME'), os.getenv('SNAPCRAFT_COLLABORATORS_SIGN_KEY')) else: lifecycle.snap(project_options, args['<directory>'], args['--output']) return project_options