Skip to content

Conversation

@monyarm
Copy link
Contributor

@monyarm monyarm commented Apr 3, 2025

  • feat(mcl): Add commandline argument support
  • feat(mcl/utils/log): Implement errorAndExit function
  • feat(mcl/utils/process): Add support to execute function, for supplying redirect; Improve execute function argument escaping, to not escape globs
  • feat(mcl/config): Implement mcl config command
  • refactor(mcl/dub): Remove deprecated dflags for improved build configuration
  • fix(ci_matrix): Initialize params directly in ci_matrix function
  • fix(utils/cachix): Modify getCachixDeploymenApiUrl definition, to allow compilation with newer d compiler versions.
  • feat(mcl/main): Integrate argparse for command-line argument parsing and enhance command handling
  • feat(commands/get_fstab): Enhance get_fstab command with argparse integration and structured argument handling
  • feat(commands/deploy_spec): Enhance deploy_spec command with argparse integration and structured argument handling
  • feat(commands/host_info): Enhance host_info command with argparse integration and structured argument handling
  • feat(commands/config): Enhance config command with argparse integration and structured argument handling
  • feat(commands/machine): Enhance machine command with argparse integration and structured argument handling
  • feat(commands): Enhance ci/matrix commands with argparse integration and structured argument handling where applicable

@monyarm monyarm force-pushed the feat/mcl/jcli branch 2 times, most recently from 662b512 to a999476 Compare April 10, 2025 14:55
@PetarKirov PetarKirov mentioned this pull request Jun 4, 2025
@PetarKirov PetarKirov force-pushed the feat/mcl/jcli branch 2 times, most recently from 9ae8a89 to f67558b Compare June 4, 2025 10:12
@reo101 reo101 self-requested a review June 4, 2025 15:57
Comment on lines 189 to 196
export void print_table(string[] args)
@(Command("print-table", "print_table").Description("Print a table of the cache status of each package"))
struct print_table_args
{
}

export int print_table(print_table_args args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we instead try supporting argument-less commands by providing an aptly argument-less function returning void, with genSubCommandArgs being updated to dynamically check whether or not each sub-command handler function has arguments/return value at all before taking them into account?
This also applies to all _args structs annotated with @(Command(" ").Description(" ")).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, as as argparse SubCommands are expressed as SumTypes.

We could actually do something like this:

struct Command1
{
    // no CLI args
    
    int run() { /* ... */ }
}

struct Command2
{
    int arg1;
    string arg2;
    
    int run()
    {
        // Use `this.arg1` and `this.arg2`... 
    }
}

@PetarKirov PetarKirov force-pushed the main branch 9 times, most recently from 04b4e49 to 65172bd Compare August 6, 2025 01:23
@PetarKirov PetarKirov force-pushed the main branch 2 times, most recently from 559a043 to 9ae77e2 Compare August 23, 2025 13:47
@monyarm monyarm changed the title feat/mcl/jcli argparse Oct 24, 2025
@PetarKirov PetarKirov force-pushed the feat/mcl/jcli branch 3 times, most recently from 225118a to 6beef97 Compare November 18, 2025 16:23
Comment on lines 65 to 76
@(Command("apply").Description("Apply user configuration"))
struct home_apply_args
{
@(PositionalArgument(0).Placeholder("desktop/server").Description("Type of home configuration"))
string type;
}

@(Command("edit").Description("Edit user configuration"))
struct home_edit_args
{
@(PositionalArgument(0).Placeholder("desktop/server").Description("Type of home configuration"))
string type;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@(Command("apply").Description("Apply user configuration"))
struct home_apply_args
{
@(PositionalArgument(0).Placeholder("desktop/server").Description("Type of home configuration"))
string type;
}
@(Command("edit").Description("Edit user configuration"))
struct home_edit_args
{
@(PositionalArgument(0).Placeholder("desktop/server").Description("Type of home configuration"))
string type;
}
enum HomeConfigType { desktop, server }
@(Command("apply").Description("Apply user configuration"))
struct home_apply_args
{
@(PositionalArgument(0).Placeholder("desktop/server").Description("Type of home configuration"))
HomeConfigType type;
}
@(Command("edit").Description("Edit user configuration"))
struct home_edit_args
{
@(PositionalArgument(0).Placeholder("desktop/server").Description("Type of home configuration"))
HomeConfigType type;
}

}

void sys(string[] args)
int apply(string type, string value)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest having two separate functions:

int switchSystem(string machineName);
int switchHome(HomeConfigType type, string username);

The comment about switchHome is dependent on this change in the Justfile:

Image


if (!spec.agents.length)
return;
return 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having no configurations to deploy is ok:

Suggested change
return 1;
return 0;

Comment on lines +85 to +86
return 1;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 1;
return 0;

.toPrettyString(JSONOptions.doNotEscapeSlashes)
.writeln();

if (!params.codaApiToken) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!params.codaApiToken) {
if (args.uploadToCoda && !params.codaApiToken) {

Comment on lines +403 to +405
@(NamedArgument(["is-normal-user"]).Placeholder("true/false").Description("Is this a normal user"))
bool isNormalUser;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All users are non-system, so we don't need this option.

monyarm and others added 18 commits November 19, 2025 20:59
… integration and structured argument handling
…and structured argument handling where applicable
* Switch to nixpkgs version of `buildDubPackage`
* Use `nix-to-dub` to generate dub lock file:

    nix run nixpkgs#dub-to-nix > dub-lock.json

* Enable `checkPhase` (default is off in nixpkgs, unlike dlang.nix)
* Escape flags disabled tests flag passed to `dubTestFlags`
* Add installPhase
@github-actions
Copy link
Contributor

Thanks for your Pull Request!

Below you will find a summary of the cachix status of each package, for each supported platform.

package x86_64-linux x86_64-darwin aarch64-darwin
aztec ✅ cached 🚫 not supported ✅ cached
cachix ❌ build failed ❌ build failed ❌ build failed
dcd ✅ cached 🚫 not supported 🚫 not supported
dmd ✅ cached 🚫 not supported 🚫 not supported
dscanner ✅ cached 🚫 not supported 🚫 not supported
dub ✅ cached ✅ cached ✅ cached
erigon ✅ cached 🚫 not supported 🚫 not supported
folder-size-metrics ✅ cached 🚫 not supported 🚫 not supported
foundry ✅ cached ✅ cached ✅ cached
geth ✅ cached 🚫 not supported ✅ cached
ldc ✅ cached 🚫 not supported 🚫 not supported
lido-withdrawals-automation ✅ cached ✅ cached ✅ cached
mcl ✅ cached 🚫 not supported 🚫 not supported
mev-boost ✅ cached 🚫 not supported 🚫 not supported
nethermind ✅ cached 🚫 not supported 🚫 not supported
nimbus ✅ cached 🚫 not supported 🚫 not supported
nix ❌ build failed ❌ build failed ❌ build failed
nix-eval-jobs ❌ build failed ❌ build failed ❌ build failed
nix-fast-build ❌ build failed ❌ build failed ❌ build failed
pyroscope ✅ cached ✅ cached ✅ cached
random-alerts ✅ cached ✅ cached ✅ cached
rustToolchain ✅ cached ✅ cached ✅ cached
secret ✅ cached 🚫 not supported ✅ cached
serve-d ✅ cached 🚫 not supported 🚫 not supported
terraform ✅ cached 🚫 not supported 🚫 not supported
terranix ✅ cached 🚫 not supported 🚫 not supported
web3signer ✅ cached 🚫 not supported 🚫 not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants