Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

Commit 9370753

Browse files
committed
feat: adjust default experiments, add --all flag
Ensure that the default experiment list only includes the more stable experimnets (coreutils & sudo-rs), but also include a `--all` command line flag to enable people to go 'all in'
1 parent d6044b2 commit 9370753

File tree

7 files changed

+118
-44
lines changed

7 files changed

+118
-44
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ It currently supports the following experiments:
99
- [uutils diffutils](https://github.com/uutils/diffutils)
1010
- [sudo-rs](https://github.com/trifectatechfoundation/sudo-rs)
1111

12+
By default, the `coreutils` and `sudo-rs` experiments are enabled because they're the most complete, stable experiments. Others can be toggled using command line arguments shown below.
13+
1214
## Installation
1315

14-
> [!WARNING]
15-
> `oxidizr` is an experimental tool to help developers and tinkerers play with relatively new alternatives to core system utilities. It may cause a loss of data, or prevent your system from booting, so use with caution!
16+
> [!WARNING] > `oxidizr` is an experimental tool to help developers and tinkerers play with relatively new alternatives to core system utilities. It may cause a loss of data, or prevent your system from booting, so use with caution!
1617
1718
You can install `oxidizr` using `cargo`:
1819

@@ -47,10 +48,13 @@ Options:
4748
-y, --yes
4849
Skip confirmation prompts
4950

51+
-a, --all
52+
Enable/disable all known experiments
53+
5054
-e, --experiments <EXPERIMENTS>...
5155
Select experiments to enable or disable
5256

53-
[default: coreutils findutils diffutils sudo-rs]
57+
[default: coreutils sudo-rs]
5458

5559
-h, --help
5660
Print help (see a summary with '-h')
@@ -62,6 +66,8 @@ Options:
6266
### Example
6367

6468
```bash
69+
# Enable all experiments
70+
sudo oxidizr enable --ll
6571
# Enable just coreutils and findutils experiments
6672
sudo oxidizr enable --experiments coreutils findutils
6773
# Enable just coreutils experiment without prompting with debug logging enabled

src/main.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use clap::{Parser, Subcommand};
3636
use clap_verbosity_flag::{InfoLevel, Verbosity};
3737
use experiments::{all_experiments, Experiment};
3838
use inquire::Confirm;
39-
use tracing::info;
39+
use tracing::{info, warn};
4040
use tracing_subscriber::{fmt, prelude::*};
4141
use utils::{System, Worker};
4242

@@ -61,7 +61,16 @@ struct Args {
6161
#[arg(
6262
short,
6363
long,
64-
default_values_t = vec!["coreutils".to_string(), "findutils".to_string(), "diffutils".to_string(), "sudo-rs".to_string()],
64+
default_value_t = false,
65+
global = true,
66+
help = "Enable/disable all known experiments"
67+
)]
68+
all: bool,
69+
70+
#[arg(
71+
short,
72+
long,
73+
default_values_t = vec!["coreutils".to_string(), "sudo-rs".to_string()],
6574
global = true,
6675
num_args = 1..,
6776
help = "Select experiments to enable or disable"
@@ -105,12 +114,18 @@ fn main() -> Result<()> {
105114
"This program only supports Ubuntu"
106115
);
107116

108-
// Get the set of enabled experiments. If the user specified nothing, all experiments are
109-
// enabled.
110-
let selected_experiments: Vec<Experiment<'_>> = all_experiments(&system)
111-
.into_iter()
112-
.filter(|e| args.experiments.contains(&e.name()))
113-
.collect();
117+
let selected_experiments: Vec<Experiment<'_>> = match args.all {
118+
true => {
119+
if args.experiments.len() > 0 {
120+
warn!("Ignoring --experiments flag as --all is set");
121+
}
122+
all_experiments(&system)
123+
}
124+
false => all_experiments(&system)
125+
.into_iter()
126+
.filter(|e| args.experiments.contains(&e.name()))
127+
.collect(),
128+
};
114129

115130
// Handle subcommands
116131
match args.cmd {

tests/disable-all/task.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
summary: Test disabling experiments
2+
execute: |
3+
oxidizr enable --yes --all
4+
oxidizr disable --yes --all
5+
6+
apt list rust-coreutils | NOMATCH installed
7+
ls -la /usr/bin/date | NOMATCH "/usr/bin/date -> /usr/bin/coreutils"
8+
ls -la /usr/bin | NOMATCH ".date.oxidizr.bak"
9+
date --help | MATCH "GNU"
10+
11+
apt list rust-findutils | NOMATCH installed
12+
ls -la /usr/bin/find | NOMATCH "/usr/bin/find -> /usr/lib/cargo/bin/findutils/find"
13+
ls -la /usr/bin | NOMATCH ".find.oxidizr.bak"
14+
find --help | MATCH "GNU"
15+
16+
if [[ "$(lsb_release -rs)" != "24.04" ]]; then
17+
apt list rust-diffutils | NOMATCH installed
18+
ls -la /usr/bin/diff | NOMATCH "/usr/bin/diff -> /usr/lib/cargo/bin/diffutils/diff"
19+
ls -la /usr/bin | NOMATCH ".diff.oxidizr.bak"
20+
diff --help | MATCH "GNU"
21+
fi
22+
23+
apt list sudo-rs | NOMATCH installed
24+
25+
ls -la /usr/bin/sudo | NOMATCH "/usr/bin/sudo -> /usr/lib/cargo/bin/sudo"
26+
ls -la /usr/bin | NOMATCH ".sudo.oxidizr.bak"
27+
/usr/bin/sudo --version 2>&1 | NOMATCH "sudo-rs"
28+
29+
ls -la /usr/bin/su | NOMATCH "/usr/bin/su -> /usr/lib/cargo/bin/su"
30+
ls -la /usr/bin | NOMATCH ".su.oxidizr.bak"
31+
/usr/bin/su --version 2>&1 | NOMATCH "su-rs"
32+
33+
ls -la /usr/sbin/visudo | NOMATCH "/usr/sbin/visudo -> /usr/lib/cargo/bin/visudo"
34+
ls -la /usr/sbin | NOMATCH ".visudo.oxidizr.bak"

tests/disable-default/task.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@ execute: |
88
ls -la /usr/bin | NOMATCH ".date.oxidizr.bak"
99
date --help | MATCH "GNU"
1010
11-
apt list rust-findutils | NOMATCH installed
12-
ls -la /usr/bin/find | NOMATCH "/usr/bin/find -> /usr/lib/cargo/bin/findutils/find"
13-
ls -la /usr/bin | NOMATCH ".find.oxidizr.bak"
14-
find --help | MATCH "GNU"
15-
16-
if [[ "$(lsb_release -rs)" != "24.04" ]]; then
17-
apt list rust-diffutils | NOMATCH installed
18-
ls -la /usr/bin/diff | NOMATCH "/usr/bin/diff -> /usr/lib/cargo/bin/diffutils/diff"
19-
ls -la /usr/bin | NOMATCH ".diff.oxidizr.bak"
20-
diff --help | MATCH "GNU"
21-
fi
22-
2311
apt list sudo-rs | NOMATCH installed
2412
2513
ls -la /usr/bin/sudo | NOMATCH "/usr/bin/sudo -> /usr/lib/cargo/bin/sudo"

tests/enable-all/task.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
summary: Test enabling default experiments
2+
execute: |
3+
oxidizr enable --yes --all
4+
5+
apt list rust-coreutils | MATCH installed
6+
while read p; do
7+
util_path="$(which $p)"
8+
util_dir="$(dirname "$util_path")"
9+
ls -la "$util_path"| MATCH "$util_path -> /usr/bin/coreutils"
10+
ls -la "$util_dir/.$p.oxidizr.bak" || echo "No backup file for $util_path"
11+
$util_path --help | NOMATCH "https://www.gnu.org/software/coreutils"
12+
done < ../rust-coreutils-bins.txt
13+
14+
apt list rust-findutils | MATCH installed
15+
while read p; do
16+
util_path="$(which $p)"
17+
util_dir="$(dirname "$util_path")"
18+
ls -la "$util_path"| MATCH "$util_path -> /usr/lib/cargo/bin/findutils/$p"
19+
ls -la "$util_dir/.$p.oxidizr.bak" || echo "No backup file for $util_path"
20+
$util_path --help | NOMATCH "https://www.gnu.org/software/coreutils"
21+
done < ../rust-findutils-bins.txt
22+
23+
if [[ "$(lsb_release -rs)" != "24.04" ]]; then
24+
apt list rust-diffutils | MATCH installed
25+
while read p; do
26+
util_path="$(which $p)"
27+
util_dir="$(dirname "$util_path")"
28+
ls -la "$util_path"| MATCH "$util_path -> /usr/lib/cargo/bin/diffutils/$p"
29+
ls -la "$util_dir/.$p.oxidizr.bak" || echo "No backup file for $util_path"
30+
$util_path --help | NOMATCH "https://www.gnu.org/software/coreutils"
31+
done < ../rust-diffutils-bins.txt
32+
fi
33+
34+
apt list sudo-rs | MATCH installed
35+
36+
ls -la /usr/bin/sudo | MATCH "/usr/bin/sudo -> /usr/lib/cargo/bin/sudo"
37+
ls -la /usr/bin | MATCH ".sudo.oxidizr.bak"
38+
/usr/bin/sudo --version 2>&1 | MATCH "sudo-rs"
39+
40+
ls -la /usr/bin/su | MATCH "/usr/bin/su -> /usr/lib/cargo/bin/su"
41+
ls -la /usr/bin | MATCH ".su.oxidizr.bak"
42+
/usr/bin/su --version 2>&1 | MATCH "su-rs"
43+
44+
ls -la /usr/sbin/visudo | MATCH "/usr/sbin/visudo -> /usr/lib/cargo/bin/visudo"
45+
ls -la /usr/sbin | MATCH ".visudo.oxidizr.bak"
46+
47+
restore: |
48+
if [[ -z "${CI:-}" ]]; then
49+
oxidizr disable --yes --all
50+
fi

tests/enable-default/task.yaml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,6 @@ execute: |
1111
$util_path --help | NOMATCH "https://www.gnu.org/software/coreutils"
1212
done < ../rust-coreutils-bins.txt
1313
14-
apt list rust-findutils | MATCH installed
15-
while read p; do
16-
util_path="$(which $p)"
17-
util_dir="$(dirname "$util_path")"
18-
ls -la "$util_path"| MATCH "$util_path -> /usr/lib/cargo/bin/findutils/$p"
19-
ls -la "$util_dir/.$p.oxidizr.bak" || echo "No backup file for $util_path"
20-
$util_path --help | NOMATCH "https://www.gnu.org/software/coreutils"
21-
done < ../rust-findutils-bins.txt
22-
23-
if [[ "$(lsb_release -rs)" != "24.04" ]]; then
24-
apt list rust-diffutils | MATCH installed
25-
while read p; do
26-
util_path="$(which $p)"
27-
util_dir="$(dirname "$util_path")"
28-
ls -la "$util_path"| MATCH "$util_path -> /usr/lib/cargo/bin/diffutils/$p"
29-
ls -la "$util_dir/.$p.oxidizr.bak" || echo "No backup file for $util_path"
30-
$util_path --help | NOMATCH "https://www.gnu.org/software/coreutils"
31-
done < ../rust-diffutils-bins.txt
32-
fi
33-
3414
apt list sudo-rs | MATCH installed
3515
3616
ls -la /usr/bin/sudo | MATCH "/usr/bin/sudo -> /usr/lib/cargo/bin/sudo"
@@ -46,5 +26,5 @@ execute: |
4626
4727
restore: |
4828
if [[ -z "${CI:-}" ]]; then
49-
oxidizr disable --yes
29+
oxidizr disable --yes
5030
fi

tests/enable-partial/task.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ execute: |
1313
1414
apt list rust-findutils | NOMATCH installed
1515
apt list rust-diffutils | NOMATCH installed
16+
apt list sudo-rs | NOMATCH installed
1617
1718
restore: |
1819
if [[ -z "${CI:-}" ]]; then

0 commit comments

Comments
 (0)