@oclif/command#Command TypeScript Examples
The following examples show how to use
@oclif/command#Command.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: delete.ts From tempomat with MIT License | 6 votes |
export default class Delete extends Command {
static description = 'delete a tracker'
static examples = [
`${appName} tracker:delete abc-123`
]
static flags = {
help: flags.help({ char: 'h' }),
debug: flags.boolean()
}
static args = [
{
name: 'issue_key_or_alias',
description: 'issue key, like abc-123 or alias',
required: true
}
]
async run() {
const { args, flags } = this.parse(Delete)
globalFlags.debug = flags.debug
await tempo.deleteTracker({ issueKeyOrAlias: args.issue_key_or_alias })
}
}
Example #2
Source File: validate.ts From zcli with Apache License 2.0 | 6 votes |
export default class Validate extends Command {
static description = 'validates your app'
static args = [
{ name: 'appDirectory', default: '.', required: true, description: 'app path where manifest.json exists' }
]
static examples = [
'$ zcli apps:validate .',
'$ zcli apps:validate ./app1'
]
async run () {
const { args } = this.parse(Validate)
const { appDirectory } = args
validateAppPath(appDirectory)
const appPath = path.resolve(appDirectory)
const pkgPath = await createAppPkg(appPath)
try {
await validatePkg(pkgPath)
this.log(chalk.green('No validation errors'))
} catch (error) {
this.error(chalk.red(error))
}
// clean up
if (pkgPath) await fs.remove(pkgPath)
}
}
Example #3
Source File: package.ts From zcli with Apache License 2.0 | 6 votes |
export default class Package extends Command {
static description = 'validates and packages your app'
static args = [
{ name: 'appDirectory', default: '.', required: true, description: 'app path where manifest.json exists' }
]
static examples = [
'$ zcli apps:package .',
'$ zcli apps:package ./app1'
]
async run () {
const { args } = this.parse(Package)
const { appDirectory } = args
validateAppPath(appDirectory)
const appPath = path.resolve(appDirectory)
const pkgPath = await createAppPkg(appPath)
try {
await validatePkg(pkgPath)
this.log(chalk.green(`Package created at ${path.relative(process.cwd(), pkgPath)}`))
} catch (error) {
this.error(chalk.red(error))
}
}
}
Example #4
Source File: clean.ts From zcli with Apache License 2.0 | 6 votes |
export default class Clean extends Command {
static description = 'purges any app artifacts which have been generated locally'
static args = [
{ name: 'appPath' }
]
static examples = [
'$ zcli apps:clean ./app'
]
async run () {
const tmpDirectoryPath = path.join(process.cwd(), 'tmp')
const { args } = this.parse(Clean)
const appPath = args.appPath || './'
validateAppPath(appPath)
try {
await cleanDirectory(tmpDirectoryPath)
this.log(chalk.green(`Successfully removed ${tmpDirectoryPath} directory.`))
} catch (error) {
this.error(chalk.red(`Failed to remove ${tmpDirectoryPath} directory.`))
}
}
}
Example #5
Source File: use.ts From zcli with Apache License 2.0 | 6 votes |
export default class Remove extends Command {
static description = 'switches to a profile'
static args = [
{ name: 'subdomain', required: true }
]
static examples = [
'$ zcli profiles:use [SUBDOMAIN]'
]
async run () {
const { args } = this.parse(Remove)
const { subdomain } = args
const secureStore = new SecureStore()
const keytar = await secureStore.loadKeytar()
if (!keytar) {
console.log(chalk.yellow(`Failed to load secure credentials store: could not switch to ${subdomain} profile.`), HELP_ENV_VARS)
return
}
const auth = new Auth({ secureStore })
const profiles = await auth.getSavedProfiles()
if (profiles && profiles.length) {
const profileExists = !!profiles.filter(({ account }) => account === subdomain)?.length
if (profileExists) {
await auth.setLoggedInProfile(subdomain)
console.log(chalk.green(`Switched to ${subdomain} profile.`))
} else {
console.log(chalk.red(`Failed to find ${subdomain} profile.`))
}
} else {
console.log(chalk.red(`Failed to find ${subdomain} profile.`))
}
}
}
Example #6
Source File: remove.ts From zcli with Apache License 2.0 | 6 votes |
export default class Remove extends Command {
static description = 'removes a profile'
static args = [
{ name: 'subdomain', required: true }
]
static examples = [
'$ zcli profiles:remove [SUBDOMAIN]'
]
async run () {
const { args } = this.parse(Remove)
const { subdomain } = args
const secureStore = new SecureStore()
const keytar = await secureStore.loadKeytar()
if (!keytar) {
console.log(chalk.yellow('Failed to load secure credentials store: could not remove profile.'), HELP_ENV_VARS)
return
}
const deleted = await secureStore.deletePassword(subdomain)
if (!deleted) throw new CLIError(chalk.red(`Profile ${subdomain} not found.`))
console.log(chalk.green(`Removed ${subdomain} profile.`))
}
}
Example #7
Source File: logout.ts From zcli with Apache License 2.0 | 6 votes |
export default class Logout extends Command {
static description = 'removes an authentication token for an active profile'
static flags = {
help: flags.help({ char: 'h' }),
subdomain: flags.string({ char: 's', default: '', description: 'Zendesk Subdomain' })
}
static examples = [
'$ zcli logout'
]
async run () {
const secureStore = new SecureStore()
const keytar = await secureStore.loadKeytar()
if (!keytar) {
console.log(chalk.yellow('Secure credentials store not found.'))
return
}
const auth = new Auth({ secureStore })
const success = await auth.logout()
if (success) {
console.log(chalk.green('Successfully logged out.'))
}
}
}
Example #8
Source File: login.ts From zcli with Apache License 2.0 | 6 votes |
export default class Login extends Command {
static description = 'creates and/or saves an authentication token for the specified subdomain'
static flags = {
help: flags.help({ char: 'h' }),
subdomain: flags.string({ char: 's', default: '', description: 'Zendesk Subdomain' }),
interactive: flags.boolean({ char: 'i', default: false, description: 'Use Terminal based login' })
}
static examples = [
'$ zcli login -i',
'$ zcli login -s zendesk-subdomain -i'
]
async run () {
const secureStore = new SecureStore()
const keytar = await secureStore.loadKeytar()
if (!keytar) {
console.log(chalk.yellow('Failed to load secure credentials store: use environment variables to log in.'), HELP_ENV_VARS)
return
}
const { flags } = this.parse(Login)
const { interactive, subdomain } = flags
if (interactive) {
const auth = new Auth({ secureStore })
const success = await auth.loginInteractively({ subdomain })
if (success) {
console.log(chalk.green('Successfully logged in.'))
} else {
console.log(chalk.red(`Failed to log in to your account: ${subdomain}.`))
}
} else {
console.log('Browser login coming soon, use `zcli login -i` for interactive logins.')
}
}
}
Example #9
Source File: stop.ts From tempomat with MIT License | 6 votes |
export default class Stop extends Command {
static description = '[or stop], stop a tracker and log it'
static examples = [
`${appName} tracker:stop abc-123`,
`${appName} stop abc-123`,
`${appName} tracker:stop abc-123 -d "worklog description"`
]
static aliases = ['stop']
static flags = {
help: flags.help({ char: 'h' }),
debug: flags.boolean(),
description: flags.string({ char: 'd', description: 'description for worklog' }),
'remaining-estimate': flags.string({ char: 'r', description: 'remaining estimate' })
}
static args = [
{
name: 'issue_key_or_alias',
description: 'issue key, like abc-123 or alias',
required: true
}
]
async run() {
const { args, flags } = this.parse(Stop)
globalFlags.debug = flags.debug
await tempo.stopTracker({
issueKeyOrAlias: args.issue_key_or_alias,
description: flags.description,
remainingEstimate: flags['remaining-estimate'],
now: time.now()
})
}
}
Example #10
Source File: start.ts From tempomat with MIT License | 6 votes |
export default class Start extends Command {
static description = '[or start], start a new tracker'
static examples = [
`${appName} tracker:start abc-123`,
`${appName} start abc-123`,
`${appName} tracker:start abc-123 -d "worklog description"`
]
static aliases = ['start']
static flags = {
help: flags.help({ char: 'h' }),
debug: flags.boolean(),
description: flags.string({ char: 'd', description: 'description for worklog once tracker is stopped' }),
'stop-previous': flags.boolean({ description: 'stops and logs previous tracker with the same issue key if it exists' })
}
static args = [
{
name: 'issue_key_or_alias',
description: 'issue key, like abc-123 or alias',
required: true
}
]
async run() {
const { args, flags } = this.parse(Start)
globalFlags.debug = flags.debug
await tempo.startTracker({
issueKeyOrAlias: args.issue_key_or_alias,
description: flags.description,
now: time.now(),
stopPreviousTracker: flags['stop-previous']
})
}
}
Example #11
Source File: resume.ts From tempomat with MIT License | 6 votes |
export default class Resume extends Command {
static description = '[or resume], resume a tracker that is currently paused'
static examples = [
`${appName} tracker:resume abc-123`,
`${appName} resume abc-123`
]
static aliases = ['resume']
static flags = {
help: flags.help({ char: 'h' }),
debug: flags.boolean()
}
static args = [
{
name: 'issue_key_or_alias',
description: 'issue key, like abc-123 or alias',
required: true
}
]
async run() {
const { args, flags } = this.parse(Resume)
globalFlags.debug = flags.debug
await tempo.resumeTracker({
issueKeyOrAlias: args.issue_key_or_alias,
now: time.now()
})
}
}
Example #12
Source File: pause.ts From tempomat with MIT License | 6 votes |
export default class Pause extends Command {
static description = '[or pause], pause a tracker that is currently running'
static examples = [
`${appName} tracker:pause abc-123`,
`${appName} pause abc-123`
]
static aliases = ['pause']
static flags = {
help: flags.help({ char: 'h' }),
debug: flags.boolean()
}
static args = [
{
name: 'issue_key_or_alias',
description: 'issue key, like abc-123 or alias',
required: true
}
]
async run() {
const { args, flags } = this.parse(Pause)
globalFlags.debug = flags.debug
await tempo.pauseTracker({
issueKeyOrAlias: args.issue_key_or_alias,
now: time.now()
})
}
}
Example #13
Source File: list.ts From tempomat with MIT License | 6 votes |
export default class List extends Command {
static description = 'list all trackers'
static examples = [
`${appName} tracker:list`
]
async run() {
await tempo.listTrackers(time.now())
}
}
Example #14
Source File: setup.ts From tempomat with MIT License | 6 votes |
export default class Setup extends Command {
static description = 'setup cli, this is required before the first use'
static examples = [
`${appName} setup`
]
async run() {
await tempo.setup()
}
}
Example #15
Source File: list.ts From tempomat with MIT License | 6 votes |
export default class List extends Command {
static description = '[or ls], print worklogs from provided date (YYYY-MM-DD or \'y\' as yesterday)'
static examples = [
`${appName} list`,
`${appName} ls`,
`${appName} list y `,
`${appName} list yesterday `,
`${appName} list 2020-02-17`,
`${appName} list -v`
]
static aliases = ['ls']
static flags = {
help: flags.help({ char: 'h' }),
debug: flags.boolean(),
verbose: flags.boolean({
char: 'v',
description: 'verbose output with description and task link'
})
}
static args = [{
name: 'when',
description: trimIndent(`date to fetch worklogs, defaulted to today
* date in YYYY-MM-DD format
* y as yesterday`),
required: false
}]
async run() {
const { args, flags } = this.parse(List)
globalFlags.debug = flags.debug
await tempo.listUserWorklogs(args.when, flags.verbose)
}
}
Example #16
Source File: delete.ts From tempomat with MIT License | 6 votes |
export default class Delete extends Command {
static description = '[or d], delete the worklog with given id, this can be used also to delete a multiple worklogs'
static examples = [
`${appName} delete 123456`,
`${appName} d 123456`,
`${appName} delete 123456 123457`
]
static strict = false
static aliases = ['d']
static flags = {
help: flags.help({ char: 'h' }),
debug: flags.boolean()
}
static args = [
{
name: 'worklog_id',
description: 'worklog ids to delete, like 123456',
required: true
}
]
async run() {
const { argv, flags } = this.parse(Delete)
globalFlags.debug = flags.debug
await tempo.deleteWorklogs(argv)
}
}
Example #17
Source File: list.ts From tempomat with MIT License | 6 votes |
export default class List extends Command {
static description = 'print aliases list'
static examples = [
`${appName} alias:list`
]
static flags = {
help: flags.help({ char: 'h' }),
debug: flags.boolean()
}
async run() {
const { flags } = this.parse(List)
globalFlags.debug = flags.debug
tempo.listAliases()
}
}
Example #18
Source File: validMigrateTarget.ts From elasticsearch-index-migrate with MIT License | 6 votes |
// ToDo Delete(v1.0.0) this function after removing the flags.
export function validMigrateTarget() {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
return function (
_target: Command,
_propertyKey: string,
descriptor: TypedPropertyDescriptor<() => Promise<void>>
) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const originalCommand = descriptor.value!;
descriptor.value = async function (this: Command, ...cmdArgs: unknown[]) {
await validate.call(this, originalCommand, cmdArgs);
};
};
}
Example #19
Source File: validMigrateTarget.ts From elasticsearch-index-migrate with MIT License | 6 votes |
async function validate(
this: Command,
originalRunCommand: (...args: unknown[]) => Promise<void>,
cmdArgs: unknown[]
) {
const { flags, args } = this.parse();
const { indexName } = flags as any;
if (indexName) {
cli.warn(
'The index flags will be removed in the version 1.0.0. Please use the arguments (name) instead of this flags.'
);
}
if (!indexName && !args.name) {
cli.error(`Migration target is unknown. Please specify an argument (name).`);
}
await originalRunCommand.apply(this, cmdArgs);
}
Example #20
Source File: clone.ts From harness-cli with Apache License 2.0 | 6 votes |
export default class GitClone extends Command {
static description = 'describe the command here'
static hidden = true
static flags = {
ref: flags.string({ default: 'master' }),
cwd: flags.string({ }),
token: flags.string({ description: 'Github personal access token'}),
username: flags.string({ description: 'Github username'}),
password: flags.string({ description: 'Github password'}),
}
static args = [{name: 'repo'}]
async run(): Promise<void> {
const {args, flags} = this.parse(GitClone)
const git = new Git({
repo: args.repo,
ref: flags.ref,
cwd: flags.cwd,
auth: {
token: flags.token,
},
})
await git.clone()
}
}
Example #21
Source File: create-repo.ts From harness-cli with Apache License 2.0 | 6 votes |
export default class GithubRepoCreate extends Command {
static description = 'Create a new GitHub Repository in an Organization'
static flags = {
org: flags.string({ description: 'The Github organization', required: true }),
repo: flags.string({ description: 'The repository name', required: true }),
token: flags.string({ description: 'The GitHub token for authentication. This can also be set via the environment variable GITHUB_TOKEN.', required: true, env: 'GITHUB_TOKEN' }),
description: flags.string({ description: 'A description of the application' }),
baseUrl: flags.string({ description: 'The Github API base url', default: 'https://api.github.com' }),
visibility: flags.enum<RepoVisibility>({ options: [RepoVisibility.PRIVATE, RepoVisibility.PUBLIC, RepoVisibility.INTERNAL], description: 'Visibility settings for the repository', default: RepoVisibility.PRIVATE }),
}
async run() {
const { flags } = this.parse(GithubRepoCreate)
const github = new Github({
token: flags.token,
type: CredentialType.Git,
}, flags.baseUrl)
await github.createRepo(flags.org, flags.repo, flags.description, flags.visibility)
}
}
Example #22
Source File: create-namespace.ts From harness-cli with Apache License 2.0 | 6 votes |
export default class K8sCreateNamespace extends Command {
static description = 'Create a new Kubernetes namespace'
static flags = {
name: flags.string({ description: 'The name of the new namespace', required: true }),
kubeconfig: flags.string({ description: 'Path to a kubeconfig file. If not specified, the following search order takes precedence: KUBECONFIG environment variable, default kubectl config file (i.e. ~/.kube/config).'}),
}
async run() {
const { flags } = this.parse(K8sCreateNamespace)
const k8s = await Kubernetes.getClient(undefined, flags.kubeconfig)
const result = await k8s.namepaces.create(flags.name)
this.debug(result)
}
}
Example #23
Source File: delete.ts From tempomat with MIT License | 6 votes |
export default class Delete extends Command {
static description = 'delete issue key alias'
static examples = [
`${appName} alias:delete lunch`
]
static flags = {
help: flags.help({ char: 'h' }),
debug: flags.boolean()
}
static args = [
{
name: 'alias_name',
required: true
}
]
async run() {
const { args, flags } = this.parse(Delete)
globalFlags.debug = flags.debug
tempo.deleteAlias(args.alias_name)
}
}
Example #24
Source File: set.ts From tempomat with MIT License | 6 votes |
export default class Set extends Command {
static description = 'set issue key alias, then alias can be used instead of issue key'
static examples = [
`${appName} alias:set lunch abc-123`
]
static flags = {
help: flags.help({ char: 'h' }),
debug: flags.boolean()
}
static args = [
{
name: 'alias_name',
required: true
},
{
name: 'issue_key',
description: 'issue key, like abc-123',
required: true
}
]
async run() {
const { args, flags } = this.parse(Set)
globalFlags.debug = flags.debug
tempo.setAlias(args.alias_name, args.issue_key)
}
}
Example #25
Source File: unbundle.ts From luabundler with MIT License | 5 votes |
export default class UnbundleCommand extends Command {
static description = 'Unbundles a Lua bundle into individual files'
static flags = {
help: flags.help({char: 'h'}),
modules: flags.string({char: 'm', description: 'Output directory path where modules should be written.'}),
extension: flags.string({char: 'e', description: 'File extension of output modules. Only relevant when --modules (-m) is specified.', default: 'lua'}),
output: flags.string({char: 'o', description: 'Output path of the root (entry point) module.'}),
version: flags.version({char: 'v'}),
}
static args = [
{
name: 'file',
required: false,
description: 'Lua bundle file path. May be omitted to read from stdin instead.',
},
]
async run() {
const {args, flags} = this.parse(UnbundleCommand)
const {extension, modules, output} = flags
const options: UnbundleOptions = {
rootOnly: !modules,
}
let unbundled
if (!args.file || args.file === '-') {
unbundled = unbundleString(await readStdin(), options)
} else {
unbundled = unbundle(args.file, options)
}
if (modules) {
const modulesDir = resolvePath(modules)
if (!existsSync(modulesDir)) {
mkdirSync(modulesDir, {recursive: true})
}
for (const module of Object.values<Module>(unbundled.modules)) {
if (module.name !== unbundled.metadata.rootModuleName) {
const modulePath = resolvePath(modulesDir, module.name) + (extension ? '.' + extension : '')
const moduleDir = dirname(modulePath)
if (!existsSync(moduleDir)) {
mkdirSync(moduleDir, {recursive: true})
}
writeFileSync(modulePath, module.content)
}
}
}
const rootModule = unbundled.modules[unbundled.metadata.rootModuleName]
if (output) {
const outputPath = resolvePath(output)
const outputDir = dirname(outputPath)
if (!existsSync(outputDir)) {
mkdirSync(outputDir, {recursive: true})
}
writeFileSync(outputPath, rootModule.content)
} else {
console.log(rootModule.content)
}
}
}
Example #26
Source File: bundle.ts From luabundler with MIT License | 5 votes |
export default class BundleCommand extends Command {
static description = 'Bundles a Lua file and its dependencies into a single file'
static flags = {
help: flags.help({char: 'h'}),
isolate: flags.boolean({char: 'i', description: 'Disables require() fallback at runtime for modules not found in the bundle.', default: false}),
lua: flags.enum<LuaVersion>({char: 'l', description: 'Lua syntax version', options: luaVersions, default: '5.3'}),
output: flags.string({char: 'o', description: 'Bundle output path'}),
path: flags.string({char: 'p', description: 'Add a require path pattern', multiple: true, required: true}),
version: flags.version({char: 'v'}),
}
static args = [
{
name: 'file',
required: false,
description: 'Lua entry-point module file path. May be omitted to read from stdin instead.',
},
]
async run() {
const {args, flags} = this.parse(BundleCommand)
const options: BundleOptions = {
luaVersion: flags.lua,
isolate: flags.isolate,
expressionHandler: (module: Module, expression: Expression) => {
const start = expression.loc!.start
console.warn(`WARNING: Non-literal require found in '${module.name}' at ${start.line}:${start.column}`)
},
}
if (flags.path.length > 0) {
options.paths = flags.path
}
let content
if (!args.file || args.file === '-') {
content = bundleString(await readStdin(), options)
} else {
content = bundle(args.file, options)
}
if (flags.output) {
const resolvedPath = resolvePath(flags.output)
const resolvedDir = dirname(resolvedPath)
if (!existsSync(resolvedDir)) {
mkdirSync(resolvedDir, {recursive: true})
}
writeFileSync(flags.output, content)
} else {
console.log(content)
}
}
}
Example #27
Source File: update.ts From zcli with Apache License 2.0 | 5 votes |
export default class Update extends Command {
static description = 'updates an existing private app in the Zendesk products specified in the apps manifest file.'
static args = [
{ name: 'appDirectories', required: true, default: '.' }
]
static strict = false
getAppID (appPath: string) {
const allConfigs = getAllConfigs(appPath)
const app_id = allConfigs ? allConfigs.app_id : undefined
if (!app_id) { throw new CLIError(chalk.red('App ID not found')) }
return app_id
}
async installApp (appConfig: ZcliConfigFileContent, uploadId: number, appPath: string, manifest: Manifest) {
cli.action.start('Deploying app')
const { job_id } = await deployApp('PUT', `api/v2/apps/${appConfig.app_id}`, uploadId)
try {
const { app_id }: any = await getUploadJobStatus(job_id, appPath)
cli.action.stop('Deployed')
Object.keys(manifest.location).forEach(async product => {
if (!updateProductInstallation(appConfig, manifest, app_id, product)) {
this.error(chalk.red(`Failed to update ${manifest.name} with app_id: ${app_id}`))
}
})
this.log(chalk.green(`Successfully updated app: ${manifest.name} with app_id: ${app_id}`))
} catch (error) {
cli.action.stop('Failed')
this.error(chalk.red(error))
}
}
async run () {
const { argv: appDirectories } = this.parse(Update)
for (const appPath of appDirectories) {
validateAppPath(appPath)
cli.action.start('Uploading app')
const appConfig = getAllConfigs(appPath) || {}
const manifest = getManifestFile(appPath)
const pkgPath = await createAppPkg(appPath)
const { id: upload_id } = await uploadAppPkg(pkgPath)
if (!upload_id) {
cli.action.stop('Failed')
this.error(`Failed to upload app ${manifest.name}`)
}
cli.action.stop('Uploaded')
try {
await this.installApp(appConfig, upload_id, appPath, manifest)
} catch (error) {
this.error(chalk.red(error))
}
}
}
}
Example #28
Source File: log.ts From tempomat with MIT License | 5 votes |
export default class Log extends Command {
static description = '[or l], add a new worklog using duration or interval (abc-123 15m or abc-123 11-12:30)'
static examples = [
`${appName} log abc-123 1h `,
`${appName} l abc-123 1h `,
`${appName} log abc-123 15m `,
`${appName} log abc-123 1h15m `,
`${appName} log abc-123 11-14`,
`${appName} log abc-123 11-14:30`,
`${appName} log abc-123 11:35-14:20 `,
`${appName} log abc-123 11.35-14.20 `,
`${appName} log abc-123 1h15m 2019-02-17`,
`${appName} log abc-123 1h15m y`,
`${appName} log abc-123 1h15m yesterday`,
`${appName} log abc-123 1h15m -d "worklog description"`,
`${appName} log abc-123 1h15m --start 10:30`,
`${appName} log abc-123 1h15m -s 9`
]
static aliases = ['l']
static flags = {
help: flags.help({ char: 'h' }),
debug: flags.boolean(),
description: flags.string({
char: 'd',
description: 'worklog description'
}),
start: flags.string({
char: 's',
description: 'start time (HH:mm format), used when the input is a duration'
}),
'remaining-estimate': flags.string({
char: 'r',
description: 'remaining estimate'
})
}
static args = [
{
name: 'issue_key_or_alias',
description: 'issue key, like abc-123 or alias',
required: true
},
{
name: 'duration_or_interval',
description: 'worklog duration (e.g 15m) or interval (e.g 11:30-14)',
required: true
},
{
name: 'when',
description: trimIndent(`date to add worklog, defaulted to today
* date in YYYY-MM-DD format
* y as yesterday`),
required: false
}
]
async run() {
const { args, flags } = this.parse(Log)
globalFlags.debug = flags.debug
await tempo.addWorklog({
issueKeyOrAlias: args.issue_key_or_alias,
durationOrInterval: args.duration_or_interval,
when: args.when,
description: flags.description,
startTime: flags.start,
remainingEstimate: flags['remaining-estimate']
})
}
}
Example #29
Source File: list.ts From zcli with Apache License 2.0 | 5 votes |
export default class List extends Command {
static description = 'lists all the profiles'
static examples = [
'$ zcli profiles'
]
renderProfiles (profiles: Credential[], loggedInProfile: Profile | undefined) {
cli.table(profiles, {
account: {
header: 'Subdomains',
get: row => {
let log = row.account
if (row.account === loggedInProfile?.subdomain) {
log = `${log} ${chalk.bold.green('<= active')}`
}
return log
}
}
}, {
printLine: this.log
})
}
async run () {
const secureStore = new SecureStore()
const keytar = await secureStore.loadKeytar()
if (!keytar) {
console.log(chalk.yellow('Failed to load secure credentials store: could not load profiles.'), HELP_ENV_VARS)
return
}
const auth = new Auth({ secureStore })
const profiles = await auth.getSavedProfiles()
if (profiles && profiles.length) {
const loggedInProfile = await auth.getLoggedInProfile()
this.renderProfiles(profiles, loggedInProfile)
} else {
console.log('No profiles were found, use `zcli login` to create an active profile.')
}
}
}