Skip to content

Commit

Permalink
call auth key with snoot
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Aug 12, 2019
1 parent ee6107d commit 9ed78de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 44 deletions.
7 changes: 4 additions & 3 deletions commands/create-snoot.js
Expand Up @@ -28,7 +28,7 @@ async function getKeysFromGithub (githubUsername) {
.then(response => response.text())
}

module.exports = async function createSnoot () {
module.exports = async function createSnoot ({snoot: name = ""}) {
let hasPrivilege = unix.checkYourPrivilege()

if (!hasPrivilege) {
Expand All @@ -45,7 +45,8 @@ module.exports = async function createSnoot () {
type: "input",
name: "snoot",
message: "oh, a new snoot? 💕 \nwhat's their name?",
validate: snoots.validateName
validate: snoots.validateName,
default: name
},
{
type: "list",
Expand All @@ -72,7 +73,7 @@ module.exports = async function createSnoot () {
}

let existingKeys = snootAlreadyExists && (
await snoots.getAuthorizedKeys()
await snoots.getAuthorizedKeys(snoot)
)

let {
Expand Down
58 changes: 17 additions & 41 deletions index.js
Expand Up @@ -14,55 +14,31 @@ let noop = Function.prototype

let positionalSnoot = yargs =>
yargs.positional("snoot", {
describe: "the name of the snoot you'd like to enter"
describe: "the name of the snoot you'd like",
})

let arguments = yargs
.command(["create", "new"], "create a new snoot", noop, createSnoot)
yargs
.command(
["create <snoot>", "new <snoot>"],
"create a new snoot",
positionalSnoot,
createSnoot
)
.command(["ls", "list"], "list snoots", noop, ls)
.command(
"enter <snoot>",
"enter a snoot's container",
positionalSnoot,
enterSnoot
)
.command("get <snoot> <key>", "get snoot data", yargs => {
positionalSnoot(yargs)
.positional("key", {
describe: "the key for the data you'd like to see"
})
}, get)
.command(
"each <command>",
"run a command in each snoot",
yargs => yargs.positional(
"command", {
describe: "the command to run. the env variable SNOOT_NAME will be set with snoot's name"
}
),
each
)
.command(
"start <snoot>",
"start a snoot's container",
positionalSnoot,
startSnoot
)
.command(
"stop <snoot>",
"stop a snoot's container",
positionalSnoot,
stopSnoot
)
.command(
"exec <snoot> <command>",
"run a command in a snoot's container",
yargs =>
positionalSnoot(yargs)
.positional("command", {
describe: "the command to run"
}),
stopSnoot
"get <snoot> <key>",
"get snoot data",
yargs => {
positionalSnoot(yargs).positional("key", {
describe: "the key for the data you'd like to see",
})
},
get
)
.demandCommand()
.argv
.demandCommand().argv

0 comments on commit 9ed78de

Please sign in to comment.