-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
103 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { CMD } from '../../interfaces.js'; | ||
import Config from '../../helpers/config.js'; | ||
import YargsOptions from '../../helpers/yargs-options.js'; | ||
import Jobs from '../../helpers/jobs.js'; | ||
import reply from '../../helpers/reply.js'; | ||
|
||
const yargsOptions = new YargsOptions(); | ||
|
||
export default { | ||
command: 'export <cluster-alias> <job-id...>', | ||
describe: 'Export job or jobs on a cluster to a json file. By default the file is saved as ~/.teraslice/export/<cluster-alias>/<job.name>.json\n', | ||
builder(yargs: any) { | ||
yargs.positional('job-id', yargsOptions.buildPositional('job-id')); | ||
yargs.options('config-dir', yargsOptions.buildOption('config-dir')); | ||
yargs.options('export-dir', yargsOptions.buildOption('export-dir')); | ||
yargs.options('output', yargsOptions.buildOption('output')); | ||
yargs.options('file-name', yargsOptions.buildOption('file-name')); | ||
yargs.check((argv: { jobId: string[]; fileName: string[]; }) => { | ||
if (argv.fileName && argv.jobId.length !== argv.fileName.length) { | ||
throw new Error('The number of job IDs must match the number of file names'); | ||
} | ||
return true; | ||
}); | ||
// yargs.options('yes', yargsOptions.buildOption('yes')); | ||
// yargs.options('status', yargsOptions.buildOption('jobs-status')); | ||
yargs.strict() | ||
.example('$0 jobs export CLUSTER_ALIAS JOB1', 'exports job config as a tjm compatible JSON file') | ||
.example('$0 jobs export CLUSTER_ALIAS JOB1 JOB2', 'exports job config for two jobs') | ||
.example('$0 jobs export CLUSTER_ALIAS JOB1 JOB2 --file-name name1.json name2.json', 'exports two jobs with custom file names') | ||
.example('$0 jobs export CLUSTER_ALIAS JOB1 --export-dir ./my_jobs --f job_1.json', 'exports ajob to ./my_jobs/job_1.json'); | ||
// .example('$0 jobs export CLUSTER_ALIAS all --status failing', 'exports all failing jobs on a cluster') | ||
Check failure on line 31 in packages/teraslice-cli/src/cmds/jobs/export.ts
|
||
// .example('$0 jobs export CLUSTER_ALIAS all -y', 'exports all jobs on a cluster and bypasses the prompt'); | ||
Check failure on line 32 in packages/teraslice-cli/src/cmds/jobs/export.ts
|
||
return yargs; | ||
}, | ||
async handler(argv: any) { | ||
const cliConfig = new Config(argv); | ||
const jobs = new Jobs(cliConfig); | ||
|
||
try { | ||
await jobs.initialize(); | ||
await jobs.export(); | ||
} catch (e) { | ||
reply.fatal(e); | ||
} | ||
} | ||
} as CMD; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters