Skip to content

Commit ab8ad30

Browse files
update(cli): add --raw argument and infos
1 parent ae74b3f commit ab8ad30

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ three-style search --gen RUE --edges UF UB LF --depth 5
3535
# shorter versions
3636
three-style search -g RUD -c UFR UBL RFD -d 4
3737
three-style search -g RUE -e UF UB LF -d 5
38+
39+
three-style help
3840
```
3941

4042
> [!NOTE]
41-
> Depth is relative to the length of the commutator in its notation form.
43+
> Depth is relative to the length of the commutator in its notation form and expanded commutators are reduced by default, meaning cancellations are taken into account.
4244
4345
## Concept
4446

three-style-cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ readme = "../README.md"
1212

1313
[dependencies]
1414
clap = { version = "4.5.1", features = ["derive", "color"] }
15-
three-style-lib = "0.1.1"
15+
three-style-lib = "0.1.2"

three-style-cli/src/main.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ impl Cli {
3232
edges,
3333
gen,
3434
depth,
35+
raw,
3536
}) = self.command
3637
{
3738
let allowed_moves = gen
@@ -46,7 +47,7 @@ impl Cli {
4647
};
4748
let end = Instant::now();
4849

49-
print_commutators(commutators, end - start);
50+
print_commutators(commutators, end - start, raw);
5051
}
5152

5253
Ok(())
@@ -62,17 +63,20 @@ enum Command {
6263
.args(&["corners", "edges"]),
6364
))]
6465
Search {
65-
#[arg(long, short, num_args(3))]
66+
#[arg(long, short, num_args(3), help = "Corner cycle")]
6667
corners: Option<Vec<String>>,
6768

68-
#[arg(long, short, num_args(3))]
69+
#[arg(long, short, num_args(3), help = "Edge cycle")]
6970
edges: Option<Vec<String>>,
7071

71-
#[arg(long, short)]
72+
#[arg(long, short, help = "Allwed movesets")]
7273
gen: String,
7374

74-
#[arg(long, short)]
75+
#[arg(long, short, help = "Maximum search depth")]
7576
depth: u8,
77+
78+
#[arg(long, short, help = "Display the non-reduced algorithm")]
79+
raw: bool,
7680
},
7781
}
7882

@@ -106,21 +110,18 @@ fn search_edge_commutators(
106110
Ok(results)
107111
}
108112

109-
fn print_commutators(commutators: Vec<Commutator>, duration: Duration) {
113+
fn print_commutators(commutators: Vec<Commutator>, duration: Duration, raw: bool) {
110114
let count = commutators.len();
111115
let duration = duration.as_secs_f32();
112116
let green = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Green)));
113117

114118
for comm in commutators {
115119
let bold = Style::new().bold();
116120
let cyan = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Cyan)));
121+
let alg = comm.expand();
122+
let alg = if raw { alg } else { alg.reduce() };
117123

118-
println!(
119-
"{bold}{}{bold:#}: {} {cyan}({}){cyan:#}",
120-
comm,
121-
comm.expand(),
122-
comm.expand().len()
123-
);
124+
println!("{bold}{comm}{bold:#}: {alg} {cyan}({}){cyan:#}", alg.len());
124125
}
125126

126127
if count > 0 {

0 commit comments

Comments
 (0)