Skip to content

Commit

Permalink
Adding some short aliases for available commands
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaschiasson committed Jul 10, 2023
1 parent 934d5fe commit 2ae6ac0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ Fragmented Classless Inter-Domain Routing (FCIDR)
Usage: fcidr [CIDR] <COMMAND>
Commands:
complement Compute the complement of the input CIDR(s)
difference Compute the set difference between the input CIDR(s) and another CIDR [aliases: exclude, minus]
union Compute the set union of the input CIDR(s) and another CIDR [aliases: include, plus]
complement Compute the complement of the input CIDR(s) [aliases: !, not]
difference Compute the set difference between the input CIDR(s) and another CIDR [aliases: -, exclude, minus]
union Compute the set union of the input CIDR(s) and another CIDR [aliases: +, include, plus]
help Print this message or the help of the given subcommand(s)
Arguments:
[CIDR] The input CIDR range and first operand to the computation. If omitted, input is taken from stdin. In this way, multiple computations can be chained together
Options:
-h, --help Print help
-V, --version Print version
-V, --version Print version`
```

### Example
Expand Down Expand Up @@ -90,3 +90,31 @@ fcidr 10.0.0.0/8 difference 10.0.64.0/20 | fcidr difference 10.0.82.0/24 | fcidr
64.0.0.0/2
128.0.0.0/1
```

Alternative concise syntax:

```
fcidr 10.0.0.0/8 + 127.0.0.0/16 | fcidr - 10.64.0.0/16 | fcidr !
0.0.0.0/5
8.0.0.0/7
10.64.0.0/16
11.0.0.0/8
12.0.0.0/6
16.0.0.0/4
32.0.0.0/3
64.0.0.0/3
96.0.0.0/4
112.0.0.0/5
120.0.0.0/6
124.0.0.0/7
126.0.0.0/8
127.1.0.0/16
127.2.0.0/15
127.4.0.0/14
127.8.0.0/13
127.16.0.0/12
127.32.0.0/11
127.64.0.0/10
127.128.0.0/9
128.0.0.0/1
```
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ struct Cli {
#[derive(Debug, Subcommand)]
enum FcidrCommand {
/// Compute the complement of the input CIDR(s)
#[command(visible_alias = "!", visible_alias = "not")]
Complement,
/// Compute the set difference between the input CIDR(s) and another CIDR
#[command(visible_alias = "exclude", visible_alias = "minus")]
#[command(
visible_alias = "-",
visible_alias = "exclude",
visible_alias = "minus"
)]
Difference {
/// The second CIDR range operand for the difference function
cidr: Cidr,
},
#[command(visible_alias = "include", visible_alias = "plus")]
#[command(visible_alias = "+", visible_alias = "include", visible_alias = "plus")]
/// Compute the set union of the input CIDR(s) and another CIDR
Union {
/// The second CIDR range operand for the union function
Expand Down

0 comments on commit 2ae6ac0

Please sign in to comment.