mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-20 17:33:18 +00:00
Fix 'balena app' (rm, restart, info) with numeric app IDs
Resolves: #1815 Change-type: patch
This commit is contained in:
parent
9756efb539
commit
8d60cd1f92
@ -319,7 +319,7 @@ Examples:
|
||||
|
||||
#### NAME
|
||||
|
||||
application name
|
||||
application name or numeric ID
|
||||
|
||||
### Options
|
||||
|
||||
@ -366,7 +366,7 @@ Examples:
|
||||
|
||||
#### NAME
|
||||
|
||||
application name
|
||||
application name or numeric ID
|
||||
|
||||
### Options
|
||||
|
||||
@ -386,7 +386,7 @@ Examples:
|
||||
|
||||
#### NAME
|
||||
|
||||
application name
|
||||
application name or numeric ID
|
||||
|
||||
### Options
|
||||
|
||||
|
@ -20,6 +20,7 @@ import { stripIndent } from 'common-tags';
|
||||
import Command from '../../command';
|
||||
import * as cf from '../../utils/common-flags';
|
||||
import { getBalenaSdk, getVisuals } from '../../utils/lazy';
|
||||
import { tryAsInteger } from '../../utils/validation';
|
||||
|
||||
interface FlagsDef {
|
||||
help: void;
|
||||
@ -40,7 +41,7 @@ export default class AppCmd extends Command {
|
||||
public static args = [
|
||||
{
|
||||
name: 'name',
|
||||
description: 'application name',
|
||||
description: 'application name or numeric ID',
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
@ -58,7 +59,7 @@ export default class AppCmd extends Command {
|
||||
const { args: params } = this.parse<FlagsDef, ArgsDef>(AppCmd);
|
||||
|
||||
const application = await getBalenaSdk().models.application.get(
|
||||
params.name,
|
||||
tryAsInteger(params.name),
|
||||
);
|
||||
|
||||
console.log(
|
||||
|
@ -20,6 +20,7 @@ import { stripIndent } from 'common-tags';
|
||||
import Command from '../../command';
|
||||
import * as cf from '../../utils/common-flags';
|
||||
import { getBalenaSdk } from '../../utils/lazy';
|
||||
import { tryAsInteger } from '../../utils/validation';
|
||||
|
||||
interface FlagsDef {
|
||||
help: void;
|
||||
@ -40,7 +41,7 @@ export default class AppRestartCmd extends Command {
|
||||
public static args = [
|
||||
{
|
||||
name: 'name',
|
||||
description: 'application name',
|
||||
description: 'application name or numeric ID',
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
@ -56,6 +57,6 @@ export default class AppRestartCmd extends Command {
|
||||
public async run() {
|
||||
const { args: params } = this.parse<FlagsDef, ArgsDef>(AppRestartCmd);
|
||||
|
||||
await getBalenaSdk().models.application.restart(params.name);
|
||||
await getBalenaSdk().models.application.restart(tryAsInteger(params.name));
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import { stripIndent } from 'common-tags';
|
||||
import Command from '../../command';
|
||||
import * as cf from '../../utils/common-flags';
|
||||
import { getBalenaSdk } from '../../utils/lazy';
|
||||
import { tryAsInteger } from '../../utils/validation';
|
||||
|
||||
interface FlagsDef {
|
||||
yes: boolean;
|
||||
@ -46,7 +47,7 @@ export default class AppRmCmd extends Command {
|
||||
public static args = [
|
||||
{
|
||||
name: 'name',
|
||||
description: 'application name',
|
||||
description: 'application name or numeric ID',
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
@ -74,6 +75,6 @@ export default class AppRmCmd extends Command {
|
||||
);
|
||||
|
||||
// Remove
|
||||
await getBalenaSdk().models.application.remove(params.name);
|
||||
await getBalenaSdk().models.application.remove(tryAsInteger(params.name));
|
||||
}
|
||||
}
|
||||
|
@ -88,3 +88,14 @@ export function parseAsInteger(input: string, paramName?: string) {
|
||||
|
||||
return Number(input);
|
||||
}
|
||||
|
||||
export function tryAsInteger(
|
||||
input: string,
|
||||
paramName?: string,
|
||||
): number | string {
|
||||
try {
|
||||
return parseAsInteger(input, paramName);
|
||||
} catch {
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user