Skip to content

Commit 60b6064

Browse files
monyarmPetarKirov
authored andcommitted
feat(commands/host_info): Enhance host_info command with argparse integration and structured argument handling
1 parent 053dbe7 commit 60b6064

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

packages/mcl/src/main.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ template genSubCommandArgs()
3131
"SumType!("~
3232
"get_fstab_args,"~
3333
"deploy_spec_args,"~
34+
"host_info_args,"~
3435
"Default!unknown_command_args"~
3536
") cmd;";
3637
}

packages/mcl/src/src/mcl/commands/deploy_spec.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export int deploy_spec(deploy_spec_args args)
5858
infof("%s machines will be deployed.", spec.agents.length);
5959

6060
if (!spec.agents.length)
61-
return;
61+
return 1;
6262

6363
spawnProcessInline([
6464
"cachix", "deploy", "activate", deploySpecFile, "--async"

packages/mcl/src/src/mcl/commands/host_info.d

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import std.format : format;
1919
import std.system : nativeEndian = endian;;
2020
import core.stdc.string : strlen;
2121

22+
import argparse;
23+
2224
import mcl.utils.env : parseEnv, optional;
2325
import mcl.utils.json : toJSON;
2426
import mcl.utils.process : execute, isRoot;
@@ -30,9 +32,7 @@ import mcl.utils.coda : CodaApiClient, RowValues, CodaCell;
3032
struct Params
3133
{
3234
@optional() string codaApiToken;
33-
void setup()
34-
{
35-
}
35+
void setup() {}
3636
}
3737

3838
string[string] cpuinfo;
@@ -59,7 +59,10 @@ string[string] getProcInfo(string fileOrData, bool file = true)
5959
return r;
6060
}
6161

62-
export void host_info(string[] args)
62+
@(Command("host-info").Description("Get information about the host machine"))
63+
struct host_info_args {}
64+
65+
export int host_info(host_info_args args)
6366
{
6467
const Params params = parseEnv!Params;
6568

@@ -72,13 +75,15 @@ export void host_info(string[] args)
7275

7376
if (!params.codaApiToken) {
7477
writeln("No Coda API token specified -> not uploading");
75-
return;
78+
return 1;
7679
}
7780

7881
writeln("Coda API token specified -> uploading");
7982
auto coda = CodaApiClient(params.codaApiToken);
8083
coda.uploadHostInfo(hostInfo);
8184

85+
return 1;
86+
8287
}
8388

8489
Info gatherHostInfo()

packages/mcl/src/src/mcl/commands/package.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ public import mcl.commands.deploy_spec : deploy_spec, deploy_spec_args;
55
public import mcl.commands.ci_matrix : ci_matrix, print_table;
66
public import mcl.commands.shard_matrix : shard_matrix;
77
public import mcl.commands.ci : ci;
8-
public import mcl.commands.host_info : host_info;
8+
public import mcl.commands.host_info : host_info, host_info_args;
99
public import mcl.commands.machine : machine;
1010
public import mcl.commands.config : config;

0 commit comments

Comments
 (0)