From 9ed78de234c018de090187209e748bbd55c8b2d1 Mon Sep 17 00:00:00 2001 From: chee Date: Mon, 12 Aug 2019 23:00:11 +0100 Subject: [PATCH] call auth key with snoot --- commands/create-snoot.js | 7 ++--- index.js | 58 ++++++++++++---------------------------- 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/commands/create-snoot.js b/commands/create-snoot.js index 1cf87cd..979554f 100755 --- a/commands/create-snoot.js +++ b/commands/create-snoot.js @@ -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) { @@ -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", @@ -72,7 +73,7 @@ module.exports = async function createSnoot () { } let existingKeys = snootAlreadyExists && ( - await snoots.getAuthorizedKeys() + await snoots.getAuthorizedKeys(snoot) ) let { diff --git a/index.js b/index.js index 66c2519..f899ea7 100755 --- a/index.js +++ b/index.js @@ -14,11 +14,16 @@ 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 ", "new "], + "create a new snoot", + positionalSnoot, + createSnoot + ) .command(["ls", "list"], "list snoots", noop, ls) .command( "enter ", @@ -26,43 +31,14 @@ let arguments = yargs positionalSnoot, enterSnoot ) - .command("get ", "get snoot data", yargs => { - positionalSnoot(yargs) - .positional("key", { - describe: "the key for the data you'd like to see" - }) - }, get) .command( - "each ", - "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 ", - "start a snoot's container", - positionalSnoot, - startSnoot - ) - .command( - "stop ", - "stop a snoot's container", - positionalSnoot, - stopSnoot - ) - .command( - "exec ", - "run a command in a snoot's container", - yargs => - positionalSnoot(yargs) - .positional("command", { - describe: "the command to run" - }), - stopSnoot + "get ", + "get snoot data", + yargs => { + positionalSnoot(yargs).positional("key", { + describe: "the key for the data you'd like to see", + }) + }, + get ) - .demandCommand() - .argv + .demandCommand().argv