MCPcopy Create free account
hub / github.com/acode/cli / run

Method run

cli/commands/hostnames/remove.js:28–114  ·  view source on GitHub ↗
(params, callback)

Source from the content-addressed store, hash-verified

26 }
27
28 run(params, callback) {
29
30 let host = 'api.autocode.com';
31 let port = 443;
32
33 let listCommandFlags = {
34 h: params.flags.h,
35 p: params.flags.p
36 };
37
38 let hostname = (params.flags.h && params.flags.h[0]) || '';
39 let matches = hostname.match(/^(https?:\/\/)?(.*?)(:\d+)?$/);
40
41 if (hostname && matches) {
42 host = matches[2];
43 port = parseInt((matches[3] || '').substr(1) || (hostname.indexOf('https') === 0 ? 443 : 80));
44 }
45
46 ListCommand.prototype.run.call(this, {flags: listCommandFlags, vflags: {json: true}}, async (err, results) => {
47
48 if (err) {
49 return callback(err);
50 }
51
52 let sids = results.map(host => host.sid);
53 let answers = await inquirer.prompt(
54 [
55 {
56 name: 'route',
57 type: 'list',
58 pageSize: 100,
59 message: `Select a route to ${chalk.bold.red('Destroy (Permanently)')}`,
60 choices: tabler(
61 ['?', 'Hostname', 'Target', 'Created At'],
62 results.map((hostnameRoute, index) => {
63 return {
64 '?': ['✖', chalk.bold.red],
65 Hostname: hostnameRoute.formatted_hostname,
66 Target: hostnameRoute.target,
67 'Created At': hostnameRoute.created_at,
68 value: sids[index]
69 };
70 }),
71 true,
72 true
73 )
74 .map(row => (row.value === null ? new inquirer.Separator(row.name) : row))
75 .concat({
76 name: '○ ' + chalk.grey('(cancel)'),
77 value: 0
78 })
79 },
80 {
81 name: 'verify',
82 type: 'confirm',
83 message: answers => {
84 return (
85 `Are you sure you want to ${chalk.bold.red('permanently destroy')} ` +

Callers

nothing calls this directly

Calls 2

getMethod · 0.80
requestMethod · 0.80

Tested by

no test coverage detected