feat: harmony-cli v0.1 #8 #9
Reference in New Issue
Block a user
No description provided.
Delete Branch "harmony-cli"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Code is simple, which is good enough for a mini prototype like this.
As it evolves it will require some kind of architecture to stay clean and be extensible.
At the moment a few things are required for this PR :
cargo run -p example-cli -- --run_score SuccessScore@@ -0,0 +65,4 @@} else {let mut count = 0;let mut found = false;for s in scores_read_vec {Calling a function here that uses .iter().filter() and returns an option is more idiomatic rust (and more robust) than the
mut bool foundandmut countJust filter the array and them you can matchfiltered.len()harmony-cli initial PRto feat: harmony-cli v0.1 #8@@ -11,0 +23,4 @@-a, --all Run all or nth-n, --number <NUMBER> Run nth matching, zero indexed [default: 0]-h, --help Print help-V, --version Print versionJe viens de l'essayer, semble pas pire, mais je pense que ca prend quelques trucs pour que le UX soit correct :
cargo run -p example-cli -- -aPasser l'option -a ne fait rien quand -r n'est pas specifie.
Je m'attendais a ce que -a tout seul roule tous les scores enregistres. Ca marche avec
-r e -aIl y a plein de
clone_box()qui ne servent a rien. Pourquoi?Les scores ne sont pas lances pour vrai. On voit le log "Running: SuccessScore" mais il n'est pas vraiment execute.
/tmp/harmony-test-file-[randomsha1]559339f2ebtoee9270d771Few things to fix still :
-y --yesthat runs without prompting. When-yis not specified, prompt with something like :Do you want to run : [ List of scores matching whatever arguments are passed ] Y/n :5.1. We could also just remove the -n option for now to simplify the PR
This is just so much better. And it shows in the UX. Usually a good UX requires good code and good code produces a good UX.
Thanks for the nice work.
Some minor comments but they can all be fixed in a subsequent PR. Comments about comments are quite important though, either fix them here or in another pr, they're just smelly right now.
@@ -0,0 +50,4 @@) -> Vec<Box<dyn Score<T>>> {let scores = maestro.scores();let scores_read = scores.read().expect("Should be able to read scores");let mut scores_vec: Vec<Box<dyn Score<T>>> = match filter {So much better. I think there are more Rust idiomatic ways to handle that with Slices or something but it's good enough :
Now though you should at least reverse the map and filter calls so scores don't all get cloned for nothing.
In general you always filter your ensemble before processing.
@@ -0,0 +70,4 @@return scores_vec;}fn list_scores_with_index<T: Topology + std::fmt::Debug + Send + Sync + 'static>(This function, though pretty simple, deserves a test. Could be a good place for a doctest. Not necessary though, just spilling my thoughts.
@@ -0,0 +113,4 @@return Ok(());}// if no score to run provided, and list isn't specified, print helpEither I don't understand it or it's an outdated comment, I think those types of comment explaining WHAT the code is doing are generally bad. Comments should explain WHY. If you need to express a WHAT, use a function.
https://news.ycombinator.com/item?id=8073620
@@ -0,0 +131,4 @@}}// if all is specified, run all. Otherwise, run the first match or specified indexWeird comment here again, does not relate directly to the code block. I think I'd rather not have it.
@@ -0,0 +308,4 @@Box::new(SuccessScore {}),Box::new(ErrorScore {}),Box::new(PanicScore {}),]);Those 8 lines should be extracted to a utilty function in the test module such as "init_test_maestro() -> Maestro"