Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 4193e68

Browse files
Merge pull request #264 from Microsoft/tweaks
Command description tweaks
2 parents 4f3d807 + d378213 commit 4193e68

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

cli/script/command-executor.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,36 +105,36 @@ export var confirm = (): Promise<boolean> => {
105105
function accessKeyAdd(command: cli.IAccessKeyAddCommand): Promise<void> {
106106
return sdk.addAccessKey(command.name, command.ttl)
107107
.then((accessKey: AccessKey) => {
108-
log(`Successfully created a new access key "${command.name}": ${accessKey.key}`);
109-
log(`(Expires: ${new Date(accessKey.expires).toString()})`);
110-
log(`Please save this key as it will only be shown once!`);
108+
log(`Successfully created the "${command.name}" access key: ${accessKey.key}`);
109+
log("Make sure to save this key value somewhere safe, since you won't be able to view it from the CLI again!");
111110
});
112111
}
113112

114113
function accessKeyPatch(command: cli.IAccessKeyPatchCommand): Promise<void> {
115-
var willUpdateName: boolean = isCommandOptionSpecified(command.newName) && command.oldName !== command.newName;
116-
var willUpdateTtl: boolean = isCommandOptionSpecified(command.ttl);
114+
const willUpdateName: boolean = isCommandOptionSpecified(command.newName) && command.oldName !== command.newName;
115+
const willUpdateTtl: boolean = isCommandOptionSpecified(command.ttl);
117116

118117
if (!willUpdateName && !willUpdateTtl) {
119118
throw new Error("A new name and/or TTL must be provided.");
120119
}
121120

122121
return sdk.patchAccessKey(command.oldName, command.newName, command.ttl)
123122
.then((accessKey: AccessKey) => {
124-
var logMessage: string = "Successfully ";
123+
let logMessage: string = "Successfully ";
125124
if (willUpdateName) {
126125
logMessage += `renamed the access key "${command.oldName}" to "${command.newName}"`;
127126
}
128127

129128
if (willUpdateTtl) {
129+
const expirationDate = moment(accessKey.expires).format("LLLL");
130130
if (willUpdateName) {
131-
logMessage += ` and changed its expiry to ${new Date(accessKey.expires).toString()}`;
131+
logMessage += ` and changed its expiration date to ${expirationDate}`;
132132
} else {
133-
logMessage += `changed the access key "${command.oldName}"'s expiry to ${new Date(accessKey.expires).toString()}`;
133+
logMessage += `changed the expiration date of the "${command.oldName}" access key to ${expirationDate}`;
134134
}
135135
}
136136

137-
log(logMessage + ".");
137+
log(`${logMessage}.`);
138138
});
139139
}
140140

@@ -153,7 +153,7 @@ function accessKeyRemove(command: cli.IAccessKeyRemoveCommand): Promise<void> {
153153
if (wasConfirmed) {
154154
return sdk.removeAccessKey(command.accessKey)
155155
.then((): void => {
156-
log("Successfully removed the \"" + command.accessKey + "\" access key.");
156+
log(`Successfully removed the "${command.accessKey}" access key.`);
157157
});
158158
}
159159

@@ -1430,14 +1430,14 @@ function sessionList(command: cli.ISessionListCommand): Promise<void> {
14301430

14311431
function sessionRemove(command: cli.ISessionRemoveCommand): Promise<void> {
14321432
if (os.hostname() === command.machineName) {
1433-
throw new Error("Cannot remove the current session via this command. Please run 'code-push logout' if you would like to end it.");
1433+
throw new Error("Cannot remove the current login session via this command. Please run 'code-push logout' instead.");
14341434
} else {
14351435
return confirm()
14361436
.then((wasConfirmed: boolean): Promise<void> => {
14371437
if (wasConfirmed) {
14381438
return sdk.removeSession(command.machineName)
14391439
.then((): void => {
1440-
log(`Successfully removed the existing session for "${command.machineName}".`);
1440+
log(`Successfully removed the login session for "${command.machineName}".`);
14411441
});
14421442
}
14431443

cli/script/command-parser.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ function accessKeyAdd(commandName: string, yargs: yargs.Argv): void {
4444
isValidCommand = true;
4545
yargs.usage(USAGE_PREFIX + " access-key " + commandName + " <accessKeyName>")
4646
.demand(/*count*/ 3, /*max*/ 3) // Require exactly three non-option arguments.
47-
.example("access-key " + commandName + " \"VSTS Integration\"", "Creates a new access key with the name \"VSTS Integration\" which expires by default in 60 days")
48-
.example("access-key " + commandName + " \"One time key\" --ttl 5m", "Creates a new access key with the name \"One time key\" which expires in 5 minutes")
49-
.option("ttl", { default: null, demand: false, description: "A duration string specifying the time for which the access key remains valid for use", type: "string" });
47+
.example("access-key " + commandName + " \"VSTS Integration\"", "Creates a new access key with the name \"VSTS Integration\", which expires in 60 days")
48+
.example("access-key " + commandName + " \"One time key\" --ttl 5m", "Creates a new access key with the name \"One time key\", which expires in 5 minutes")
49+
.option("ttl", { default: "60d", demand: false, description: "Duration string which specifies the amount of time that the access key should remain valid for (e.g 5m, 60d, 1y)", type: "string" });
5050

5151
addCommonConfiguration(yargs);
5252
}
@@ -56,9 +56,9 @@ function accessKeyPatch(commandName: string, yargs: yargs.Argv): void {
5656
yargs.usage(USAGE_PREFIX + " access-key " + commandName + " <accessKeyName>")
5757
.demand(/*count*/ 3, /*max*/ 3) // Require exactly three non-option arguments.
5858
.example("access-key " + commandName + " \"Key for build server\" --name \"Key for CI machine\"", "Renames the access key named \"Key for build server\" to \"Key for CI machine\"")
59-
.example("access-key " + commandName + " \"Key for build server\" --ttl 7d", "Edits the access key named \"Key for build server\" to expire in 7 days")
60-
.option("name", { default: null, demand: false, description: "New name for the access key", type: "string" })
61-
.option("ttl", { default: null, demand: false, description: "Duration string specifying the time for which the access key remains valid for use", type: "string" });
59+
.example("access-key " + commandName + " \"Key for build server\" --ttl 7d", "Updates the access key named \"Key for build server\" to expire in 7 days")
60+
.option("name", { default: null, demand: false, description: "Display name for the access key", type: "string" })
61+
.option("ttl", { default: null, demand: false, description: "Duration string which specifies the amount of time that the access key should remain valid for (e.g 5m, 60d, 1y)", type: "string" });
6262
addCommonConfiguration(yargs);
6363
}
6464

@@ -77,7 +77,7 @@ function accessKeyRemove(commandName: string, yargs: yargs.Argv): void {
7777
isValidCommand = true;
7878
yargs.usage(USAGE_PREFIX + " access-key " + commandName + " <accessKeyName>")
7979
.demand(/*count*/ 3, /*max*/ 3) // Require exactly three non-option arguments.
80-
.example("access-key " + commandName + " 8d6513de-050c-4788-96f7-b2a50dd9684v", "Removes the \"8d6513de-050c-4788-96f7-b2a50dd9684v\" access key");
80+
.example("access-key " + commandName + " \"VSTS Integration\"", "Removes the \"VSTS Integration\" access key");
8181

8282
addCommonConfiguration(yargs);
8383
}
@@ -196,7 +196,7 @@ var argv = yargs.usage(USAGE_PREFIX + " <command>")
196196
yargs.usage(USAGE_PREFIX + " access-key <command>")
197197
.demand(/*count*/ 2, /*max*/ 2) // Require exactly two non-option arguments.
198198
.command("add", "Create a new access key associated with your account", (yargs: yargs.Argv) => accessKeyAdd("add", yargs))
199-
.command("patch", "Update the name and expiry of an access key", (yargs: yargs.Argv) => accessKeyPatch("patch", yargs))
199+
.command("patch", "Update the name and/or TTL of an existing access key", (yargs: yargs.Argv) => accessKeyPatch("patch", yargs))
200200
.command("remove", "Remove an existing access key", (yargs: yargs.Argv) => accessKeyRemove("remove", yargs))
201201
.command("rm", "Remove an existing access key", (yargs: yargs.Argv) => accessKeyRemove("rm", yargs))
202202
.command("list", "List the access keys associated with your account", (yargs: yargs.Argv) => accessKeyList("list", yargs))

0 commit comments

Comments
 (0)