Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend CLI functionality #91

Merged
merged 19 commits into from
Nov 22, 2024
Merged

Conversation

augenfrosch
Copy link
Contributor

Adds more commands and arguments to the CLI, such as a search function, the ability to specify consumables and HQ ingredients for solving, and the ability to format output in a CSV friendly way. These changes aim to make the CLI less bare-bones and provide features allowing better integration in automated workflows.

The search command and new architecture were implemented by @jfarmer with more features for the search and solve functionality added by me.

Overview:

  • Separate CLI into two commands search and solve
    • search: Search for items by their name or item ID
    • solve: Use the solver to find a solution to a craft
  • Add ability to search for recipes, like in the GUI, and look up item IDs
  • Add ability to specify food and potion used during solve
  • Allow stats to be passed with a single argument, --stats
  • Add ability to specify HQ materials used as a list of amounts
  • Allow output formatted as CSV data
    • For solve, a variety of variables can be output, depending on the arguments provided by the user
    • Both commands allow the delimiter / separator between different fields to be changed by the user

Caveats:

  • Items are specified with their item ID for the solve command. For the recipe itself, the recipe ID would also work. However, Raphael currently doesn't store it. Since there doesn't seem to be an item where different crafter's recipes differ, this should not be a problem, especially now with the search function
  • For arguments that take multiple values currently no delimiter is used, which is potentially less readable than with one. Especially for stats / is typically used when referring to different gear and meld configs. This could be changed if necessary
  • The way in which clap auto-generates the help text doesn't directly show that stats have to be provided for the solve command. Similarly, consumables are parsed with a custom function that doesn't integrate well. They lead to immediate errors, if inputted incorrectly, with a helpful error message, so this should not be too much of an issue
  • Custom recipes are not implemented

Examples:
search:

cargo run --release --package raphael-cli -- search --language en --output-field-separator ", " "arc kingd ca"
42875, Archeo Kingdom Candelarod
42922, Archeo Kingdom Hood of Casting
42923, Archeo Kingdom Coat of Casting
42924, Archeo Kingdom Armguards of Casting
42925, Archeo Kingdom Poleyns of Casting
42926, Archeo Kingdom Shoes of Casting
42931, Archeo Kingdom Earrings of Casting
42936, Archeo Kingdom Choker of Casting
42941, Archeo Kingdom Wristband of Casting
42946, Archeo Kingdom Ring of Casting

solve:

cargo run --release --package raphael-cli -- solve --item-id 42870 --stats 5408 5216 630 -m --food 44091,HQ --potion 44169,HQ --hq-ingredients 3 0 1 --output-variables item_id craftsmanship control cp initial_quality target_quality actions final_quality steps duration
42870,5408,5216,630,6656,16500,"[MuscleMemory, Veneration, WasteNot2, Groundwork, Groundwork, Groundwork, PreparatoryTouch, PreparatoryTouch, ImmaculateMend, PreparatoryTouch, PreparatoryTouch, GreatStrides, Innovation, PreparatoryTouch, GreatStrides, ByregotsBlessing, Groundwork]",16665,17,46

@KonaeAkira KonaeAkira self-requested a review November 22, 2024 21:54
if item.can_be_hq {
modified_hq_ingredients[index] =
hq_ingredients[hq_ingredient_index].clamp(0, max_amount as u8);
hq_ingredient_index = hq_ingredient_index.saturating_add(1);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have a feeling that using saturating_add here might be overkill 😂

@KonaeAkira KonaeAkira merged commit e3c5a5f into KonaeAkira:preview Nov 22, 2024
1 check passed
@augenfrosch augenfrosch deleted the dev/cli-rebased branch November 24, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants