Skip to content

Commit 6eeef88

Browse files
committed
Merge branch 'refs/heads/feat-cli-whoami-command' into feat-multiple-accounts-and-instances
2 parents d9fa0bb + ee66125 commit 6eeef88

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

templates/cli/lib/commands/generic.js.twig

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,10 @@ const loginCommand = async ({ selfHosted }) => {
8080

8181
const whoami = new Command("whoami")
8282
.description(commandDescriptions['whoami'])
83-
.configureHelp({
84-
helpWidth: process.stdout.columns || 80
85-
})
86-
.action(actionRunner(async () => {
83+
.option("-j, --json", "Output in JSON format")
84+
.action(actionRunner(async ({ json }) => {
8785
if (globalConfig.getEndpoint() === '' || globalConfig.getCookie() === '') {
88-
error("No user is signed in");
86+
error("No user is signed in. To sign in, run: appwrite login ");
8987
return;
9088
}
9189

@@ -99,20 +97,23 @@ const whoami = new Command("whoami")
9997
parseOutput: false
10098
});
10199
} catch (error) {
102-
error("No user is signed in");
100+
error("No user is signed in. To sign in, run: appwrite login");
103101
return;
104102
}
105103

106-
success("Signed in");
107-
108104
const data = [
109105
{
110106
'ID': account.$id,
111107
'Name': account.name,
112108
'Email': account.email,
113-
'MFA enabled': account.mfa
109+
'MFA enabled': account.mfa ? 'Yes' : 'No'
114110
}
115111
];
112+
if (json) {
113+
console.log(data);
114+
115+
return;
116+
}
116117

117118
drawTable(data)
118119
}));

templates/cli/lib/parser.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const commandDescriptions = {
168168
"client": `The client command allows you to configure your CLI`,
169169
"login": `The login command allows you to authenticate and manage a user account.`,
170170
"logout": `The logout command allows you to logout of your {{ spec.title|caseUcfirst }} account.`,
171-
"whoami": `The whoami command gives a basic account information about the logged in user.`,
171+
"whoami": `The whoami command gives information about the currently logged in user.`,
172172
"console" : `The console command allows gives you access to the APIs used by the Appwrite console.`,
173173
"assistant": `The assistant command allows you to interact with the Appwrite Assistant AI`,
174174
"messaging": `The messaging command allows you to send messages.`,

0 commit comments

Comments
 (0)