-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
1d429c4
commit 99c36ef
Showing
28 changed files
with
191 additions
and
24 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,36 @@ | ||
'use strict'; | ||
|
||
const program = require('commander'); | ||
const { exec } = require('shelljs'); | ||
const { | ||
devspacePath, | ||
loadState, | ||
newline, | ||
reportError, | ||
stateFilePath, | ||
} = require('./lib/c'); | ||
|
||
// The basic program, which uses sub-commands. | ||
program | ||
.option('-n', 'Do not print the trailing newline character.') | ||
.option( | ||
'-p [profile]', | ||
'Specify a minikube profile, otherwise the default minikube profile will be used.' | ||
) | ||
.parse(process.argv); | ||
|
||
const run = async () => { | ||
const devName = await loadState('devName', stateFilePath(devspacePath())); | ||
|
||
exec(`c ts ip ${devName}`, { silent: true }, (err, stdout, stderr) => { | ||
if (err) { | ||
return reportError(new Error(stderr), false, true); | ||
} | ||
|
||
process.stdout.write( | ||
`${stdout.replace(/\n/, '', 'g')}${newline(program.N)}` | ||
); | ||
}); | ||
}; | ||
|
||
run(); |
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,10 @@ | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
const program = require('commander'); | ||
const { missingCommand } = require('./lib/c'); | ||
|
||
program.command('ip', 'Manage your dev computer.').parse(process.argv); | ||
|
||
missingCommand(program); |
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,34 @@ | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
const program = require('commander'); | ||
const { | ||
loadState, | ||
devspacePath, | ||
newline, | ||
reportError, | ||
stateFilePath, | ||
} = require('./lib/c'); | ||
|
||
program | ||
.option('-n', 'Do not print the trailing newline character.') | ||
.parse(process.argv); | ||
|
||
return loadState('devName', stateFilePath(devspacePath())) | ||
.then((data) => { | ||
process.stdout.write(`${data}${newline(program.N)}`); | ||
}) | ||
.catch((err) => { | ||
if (err.code === 'ENOENT') { | ||
return reportError( | ||
new Error( | ||
"Your dev computer name hasn't been configured yet. Use `c ds dev set <dev-name>`." | ||
), | ||
false, | ||
true | ||
); | ||
} | ||
|
||
return reportError(err, false, true); | ||
}); |
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,35 @@ | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
const program = require('commander'); | ||
const { | ||
devspacePath, | ||
reportError, | ||
stateFilePath, | ||
storeState, | ||
} = require('./lib/c'); | ||
|
||
program | ||
.arguments('<dev-name>') | ||
.description("Set your dev computer's name.") | ||
.parse(process.argv); | ||
|
||
const [name] = program.args; | ||
|
||
if (!name) { | ||
return reportError( | ||
new Error("You must provide your dev computer's name."), | ||
program | ||
); | ||
} | ||
|
||
const run = async () => { | ||
try { | ||
await storeState('devName', name, stateFilePath(devspacePath())); | ||
} catch (err) { | ||
reportError(err, program, true); | ||
} | ||
}; | ||
|
||
run(); |
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,13 @@ | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
const program = require('commander'); | ||
const { missingCommand } = require('./lib/c'); | ||
|
||
program | ||
.command('get', 'Get your dev computer name.') | ||
.command('set <dev-name>', 'Set your dev computer name.') | ||
.parse(process.argv); | ||
|
||
missingCommand(program); |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env -S node --trace-warnings | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env -S node --trace-warnings | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env -S node --trace-warnings | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env -S node --trace-warnings | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env -S node --trace-warnings | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env -S node --trace-warnings | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env -S node --trace-warnings | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env -S node --trace-warnings | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
|
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env -S node --trace-warnings | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env -S node --trace-warnings | ||
#!/usr/bin/env -S node | ||
|
||
'use strict'; | ||
|
||
|
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