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

Class HostnamesRemoveCommand

cli/commands/hostnames/remove.js:12–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10const tabler = require('../../tabler.js');
11
12class HostnamesRemoveCommand extends Command {
13
14 constructor() {
15
16 super('hostnames', 'remove');
17
18 }
19
20 help() {
21
22 return {
23 description: 'Removes a hostname route from a source custom hostname to a target service you own'
24 };
25
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 };

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected