diff --git a/doc/cli.markdown b/doc/cli.markdown index a56ebaf9..df6b7fbf 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -162,7 +162,7 @@ Users are encouraged to regularly update the balena CLI to the latest version. - Application - [apps](#apps) - - [app <name>](#app-name) + - [app <nameorslug>](#app-nameorslug) - [app create <name>](#app-create-name) - [app purge <name>](#app-purge-name) - [app rename <name> [newname]](#app-rename-name-newname) @@ -324,19 +324,20 @@ Examples: No-op since release v12.0.0 -## app <name> +## app <nameOrSlug> Display detailed information about a single balena application. Examples: $ balena app MyApp + $ balena app myorg/myapp ### Arguments -#### NAME +#### NAMEORSLUG -application name or numeric ID +application name or org/name slug ### Options diff --git a/lib/commands/app/index.ts b/lib/commands/app/index.ts index 5665506b..4b05f298 100644 --- a/lib/commands/app/index.ts +++ b/lib/commands/app/index.ts @@ -26,7 +26,7 @@ interface FlagsDef { } interface ArgsDef { - name: string; + nameOrSlug: string; } export default class AppCmd extends Command { @@ -35,17 +35,17 @@ export default class AppCmd extends Command { Display detailed information about a single balena application. `; - public static examples = ['$ balena app MyApp']; + public static examples = ['$ balena app MyApp', '$ balena app myorg/myapp']; public static args = [ { - name: 'name', - description: 'application name or numeric ID', + name: 'nameOrSlug', + description: 'application name or org/name slug', required: true, }, ]; - public static usage = 'app '; + public static usage = 'app '; public static flags: flags.Input = { help: cf.help, @@ -59,22 +59,29 @@ export default class AppCmd extends Command { const { getApplication } = await import('../../utils/sdk'); - const application = (await getApplication(getBalenaSdk(), params.name, { - $expand: { - is_for__device_type: { $select: 'slug' }, - should_be_running__release: { $select: 'commit' }, + const application = (await getApplication( + getBalenaSdk(), + params.nameOrSlug, + { + $expand: { + is_for__device_type: { $select: 'slug' }, + should_be_running__release: { $select: 'commit' }, + }, }, - })) as ApplicationWithDeviceType & { + )) as ApplicationWithDeviceType & { should_be_running__release: [Release?]; + // For display purposes: + device_type: string; + commit?: string; }; - // @ts-expect-error application.device_type = application.is_for__device_type[0].slug; - // @ts-expect-error application.commit = application.should_be_running__release[0]?.commit; + + // Emulate table.vertical title output, but avoid uppercasing and inserting spaces + console.log(`== ${application.app_name}`); console.log( getVisuals().table.vertical(application, [ - `$${application.app_name}$`, 'id', 'device_type', 'slug',