MCPcopy
hub / github.com/acode/cli / run

Method run

cli/commands/user.js:62–211  ·  view source on GitHub ↗
(params, callback)

Source from the content-addressed store, hash-verified

60 }
61
62 async run(params, callback) {
63
64 let host = 'api.autocode.com';
65 let port = 443;
66
67 let hostname = (params.flags.h && params.flags.h[0]) || '';
68 let matches = hostname.match(/^(https?:\/\/)?(.*?)(:\d+)?$/);
69
70 if (hostname && matches) {
71 host = matches[2];
72 port = parseInt((matches[3] || '').substr(1) || (hostname.indexOf('https') === 0 ? 443 : 80));
73 }
74
75 let resource = new APIResource(host, port);
76 resource.authorize(config.get('ACCESS_TOKEN'));
77
78 // If resetting password
79 if (params.vflags['reset-password']) {
80 let resetEmail = params.vflags['reset-password'][0];
81 return resource.request('v1/password_reset_requests').create({}, {email: resetEmail}, (err, response) => {
82
83 if (err) {
84 return callback(err);
85 }
86
87 console.log('Password reset e-mail sent. Check the inbox for ' + resetEmail + ' for more details.');
88 return callback(null);
89
90 });
91 }
92
93 if (params.vflags['new-password']) {
94
95 let promptResult = await inquirer.prompt(
96 [
97 {
98 name: 'old_password',
99 type: 'password',
100 default: '',
101 message: 'Old Password'
102 },
103 {
104 name: 'password',
105 type: 'password',
106 default: '',
107 message: 'New Password'
108 },
109 {
110 name: 'repeat_password',
111 type: 'password',
112 default: '',
113 message: 'Repeat Password'
114 }
115 ]
116 );
117
118 resource.request('v1/users').index({me: true}, (err, response) => {
119

Callers

nothing calls this directly

Calls 2

getMethod · 0.80
requestMethod · 0.80

Tested by

no test coverage detected