Skip to content

Commit

Permalink
Add option to specify username with --instance CLI switch
Browse files Browse the repository at this point in the history
Closes #70
  • Loading branch information
alxndrsn committed May 29, 2018
1 parent 6fc3fa9 commit a8b65c8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ To upgrade to the latest version

Username `admin` is used. A prompt is shown for entering password.

If a different username is required, add the `--user` switch:

--user user-name --instance instance-name.dev

### To an arbitrary URL

medic-conf --url https://username:password@example.com:12345
Expand Down
8 changes: 7 additions & 1 deletion bin/medic-conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@ switch(args[0]) {
default: log.level = log.LEVEL_INFO;
}

let instanceUsername = 'admin';
switch(args[0]) {

//> instance URL handling:
case '--user':
instanceUsername = args[1];
shift(2);
if(args[0] !== '--instance') throw new Error('The --user switch can only be used if followed by --instance');
/* falls through */
case '--instance':
const password = readline.question(`${emoji.key} Password: `, { hideEchoBack:true });
const encodedPassword = encodeURIComponent(password);
instanceUrl = `https://admin:${encodedPassword}@${args[1]}.medicmobile.org`;
instanceUrl = `https://${instanceUsername}:${encodedPassword}@${args[1]}.medicmobile.org`;
shift(2);
break;
case '--local':
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medic-conf",
"version": "1.16.6",
"version": "1.16.7",
"description": "Configure Medic Mobile deployments",
"main": "index.js",
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion src/cli/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ ${bold('SPECIFYING URL')}
Upload to http://admin:pass@localhost:5988
--instance <instance-name>
Upload to https://admin:<password>@instance-name.medicmobile.org
Upload to https://admin:<password>@<instance-name>.medicmobile.org
--user <user-name> --instance <instance-name>
Upload to https://<user-name>:<password>@<instance-name>.medicmobile.org
--url <url>
Upload to URL specified.
Expand Down

0 comments on commit a8b65c8

Please sign in to comment.