62 lines
1.6 KiB
JavaScript
Executable File
62 lines
1.6 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
import Sync from '../src/sync'
|
|
import to from 'await-to-js'
|
|
// import logger from '@uci-utils/logger'
|
|
import yargs from 'yargs'
|
|
|
|
import readlines from '@uci-utils/read-lines'
|
|
|
|
let jobname; let command
|
|
console.log(process.argv)
|
|
let args = yargs
|
|
.boolean('w')
|
|
.alias('w','watch')
|
|
.boolean('v')
|
|
.alias('v','verbose')
|
|
.argv
|
|
console.log('yargs',args)
|
|
const cmds=['view','run','list','default','ddir','dir']
|
|
if (args._.length ===1) {
|
|
if (cmds.indexOf(args._[0])<0) jobname = args._[0]
|
|
else command = args._[0]
|
|
} else {
|
|
jobname = args._[0]
|
|
command = args._[1]
|
|
}
|
|
console.log(jobname, command)
|
|
|
|
;
|
|
(async () => {
|
|
// const log = logger({ repo: '', package:'@uci/sync', bin:'./bin/sync.js', id: 'sync-binary' })
|
|
|
|
const sync = new Sync()
|
|
|
|
if(command==='dir') { console.log(`Current Jobs Directory: ${sync.jobsDir}`)}
|
|
if(command==='dir' && jobname ) {
|
|
sync.jobsDir = jobname
|
|
console.log(`Jobs Directory set to: ${sync.jobsDir}`)
|
|
}
|
|
if(command==='ddir') { console.log(`Current Default Jobs Directory: ${sync.defaultJobsDir}`)}
|
|
if(command==='ddir' && jobname ) {
|
|
sync.defaultJobsDir = jobname=== 'reset'? null : jobname
|
|
console.log(`Setting Default Jobs Directory to: ${sync.defaultJobsDir}`)
|
|
}
|
|
if(command==='view') {
|
|
(await readlines(`${sync.JobsDir}/${jobname}`)).forEach(line=>{console.log(line)})
|
|
}
|
|
|
|
// if(!jobname) jobname = sync.getConfig('defaultJob')
|
|
// if(!jobname) {
|
|
// console.log('must specify a job or have a default job')
|
|
// return
|
|
// }
|
|
|
|
// await sync.loadJob(arg.j)
|
|
// console.log(sync.command())
|
|
|
|
|
|
|
|
})().catch(err => {
|
|
console.error('FATAL: Failed to Connecct to Remote!\n',err)
|
|
})
|