casey / casey/just

Consider allowing arguments to be mutually exclusive

Open
#3,526 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
35.8k
Forks
846
Avg merge
27m
Merged PRs (30d)
3

Description

This is apropos of #3520. Consider adding some way to declare arguments as mutually exclusive:

```just
set lists

[arg('bar', long, conflicts_with = "baz")]
[arg('baz', long)]
foo bar=[] baz=[]:
```

Workarounds are possible, but they are somewhat verbose:

```just
set lists

[arg('bar', long, conflicts_with = "baz")]
[arg('baz', long, value = (!bar && error('--baz cannot be used with --bar')))]
foo bar=[] baz=[]:
```

Similarly, arguments could require other arguments:

```just
set lists

[arg('bar', long, requires = "baz")]
[arg('baz', long)]
foo bar=[] baz=[]:
```

Another way of expressing this is as groups of arguments, which are mutually conflicting or required, but that seems like it would be a follow up after adding the basic conflicts_with/requires machinery.

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start by tracing how argument declarations are parsed and validated, then compare the proposed conflicts_with and requires examples with the current behavior. Done means the declarations can express and enforce mutually exclusive and required arguments.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.