-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat: fully configurable plz menu #110
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportPatch coverage is ❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
📢 Thoughts on this report? Let us know!. |
Hey, thanks a lot for the PR! I will probably get to this during the weekend. There seems to be some conflicts, can you check? |
take your time
fixed 👍🏻 |
Hey, sorry for taking too long but just got some time to review this. I'm actually in an airport currently and trying to wrap my head around these changes 🐻 So first of all, this is quite a large PR which begs the following questions:
I just checked the [plz_menu]
selected_pos = "Center"
[[plz_menu.entries]]
display_msg = "Show man page"
[plz_menu.entries.operation]
run = "man {cmd}"
[[plz_menu.entries]]
display_msg = "Show cheat.sh page"
[plz_menu.entries.operation]
user-agent = "fetch"
fetch = "https://cheat.sh/{cmd}{?/{subcommand}}{? {args}}"
[[plz_menu.entries]]
display_msg = "Show eg page"
[plz_menu.entries.operation]
fetch = "https://raw.githubusercontent.com/srsudar/eg/master/eg/examples/{cmd}.md"
[[plz_menu.entries]]
display_msg = "Show cheatsheets page"
[plz_menu.entries.operation]
fetch = "https://raw.githubusercontent.com/cheat/cheatsheets/master/{cmd}" Defining arrays in TOML are a bit weird already and it makes it harder to read when we have granual entries like this, Maybe we should consider merging these under one struct like Another option is to document these well in README.md and include some examples. But we should definitely look into simplifying this.
I saw that there are quite a bit of commits and it makes it harder to review everything. Maybe consider squashing some of the commits and/or creating separate PRs for finishing this.
There was some discussion about this but I guess I assumed that this will be a simple change which was lowkey wrong. So, should we go ahead with a release before this breaking change? Overall thanks for creating this! We will definitely need to tweak some parts but in the end I really want to have this feature in |
I also didn't want to be in this form initially, as I mentioned in the related issue (#96) I thought that it probably could be done in a just two-dimensional array. I found that the 2D array way would convert the code into a complete mess and it'll make it hard to maintain so I dropped that option from my list I've tried to represent the
You're not alone :)
I didn't get what you mean, can you provide some more information?
I have planned to do this already but I was waiting for this PR to get merged or at least get reviewed, so I can consider the changes when I write.
Sorry about that, am still learning
I'll do that
I guess this's the right move for now, but consider updating the https://github.com/orhun/halp/blob/main/README.md?plain=1#L236-L243 Options:
-m, --man-cmd <MAN_CMD> Sets the manual page command to run
--cheat-sh-url <URL> Use a custom URL for cheat.sh [env: CHEAT_SH_URL=]
+ --eg-url <URL> Use a custom provider URL for eg pages. [env: EG_PAGES_URL=]
+ --cheat-url <URL> Use a custom provider URL for cheat sheets. [env: ECHEATSHEETS_URL=]
-p, --pager <PAGER> Sets the pager to use
--no-pager Disables the pager
-h, --help Print help
|
da8bb01
to
ff5e89f
Compare
BREAKING CHANGE: this PR introduces a bunch of breaking changes to both the configuration system and the command-line interface. - Change the `plz` menu system to read the menu entries from the config file - Each entry contains its display string that will displayed in the menu and its operation/args - The `operation` is just a hash map that contains the operation key and its value and the rest of the arguments - Each operation has a specific set of pre-defined arguments that can be used to configure the `operation handler` and change its default behavior. - The operation handler will ignore any argument that doesn't know about - However, all the argument values will be passed to the template engine to be parsed before they are passed to the operation handler, which means that if there's any `template error` in any of the arguments the program will exit even if the argument that have the error doesn't needed by the operation handler - The currently available operations is: - `fetch` | `url`: fetch any page from the web(mainly) by HTTP - `run` | `command`: run command/s - `file`: just display the contents of any local file in the pager - Remove the following CLI options: - `--cheat-sh-url` - `--eg-url` - `--man-cmd` - `--cheat-url` - Introduce the following CLI options: - `-s` | `--selected-position`: used to set the default selected position, the posable values are: - `start`: The first item in the menu - `center`: The middle item in the menu (in case of an even number of items, the first item in the second half) - `end`: The last item in the menu COMMITS LIST: da8bb01 fix: un-use the wildcard pattern and use `as` instead (2 weeks ago) 0fdc42e chore(git): merge main and resolve confilcts (2 weeks ago) 9fd106d docs(readme): update the outdated examples (3 weeks ago) 446efff chore(config): just update the config file (3 weeks ago) a418fbd fix(test): fix the cli::update_config test and fi doc (3 weeks ago) 0187928 feat(file): create the file handler (3 weeks ago) a08101f feat(cli): add the --selected-position option to plz subcommand (3 weeks ago) 6d07d80 refactor: refactor and and lint and re-format the whole proj (3 weeks ago) 4dd0702 feat(command): create the command operation handler (3 weeks ago) 3eb71a6 refactor(plz): improve the operation handleing system (3 weeks ago) 3bb10a6 refactor: remove all the deprecate code and re-format the code (3 weeks ago) 9bfc239 revert(idea): remove the `.idea` directory (3 weeks ago) 1babee0 feat(plz): use the new system (3 weeks ago) f4d845e feat(cmd_parse): take a refrence to the hashmap (3 weeks ago) 0ed22dd feat(fetch): create the fetch handler and stabilize the `Handler` interface (3 weeks ago) 1646c14 feat(parser): cover more cases for the command parser (3 weeks ago) 5b054fb feat(parser): create the command parser (3 weeks ago) 399dfee feat(parser): create the template parser (3 weeks ago) ad409ab feat(plz): make the defualt selected item configrable (4 weeks ago) 218316a feat(plz): improve the cheat.sh url template (4 weeks ago) 08e7867 feat(plz): create the handler trait (4 weeks ago) bba0696 feat(plz): read the plz menu from the config file (4 weeks ago)
ff5e89f
to
148480b
Compare
💀 |
died pr, I was too lazy to work on the suggestions, sorry about that. but I'll try to fix it sometime soon, I hope. I was using it on my machine all this time btw. and I didn't open the config file, I didn't need to do that beside the initial time 7 months ago. so you can see why I did get lazy. |
But if someone else can fix the (de)serialization mess, I'll not say no. Am not that TOML enthusiast anyway. |
Yeah, I need to read through everything again. I don't quite remember what was the status with this. |
Description
in order to improve the project and take it to the next level, this PR introduces a bunch of breaking changes to both the configuration system and the command-line interface.
plz
menu system to read the menu entries from the config fileoperation
is just a hash map that contains the operation key and its value and the rest of the argumentsoperation handler
and change its default behavior.template error
in any of the arguments the program will exit even if the argument that have the error doesn't needed by the operation handlerfetch
|url
: fetch any page from the web(mainly) by HTTPrun
|command
: run command/sfile
: just display the contents of any local file in the pager--cheat-sh-url
--eg-url
--man-cmd
--cheat-url
-s
|--selected-position
: used to set the default selected position, the posable values are:start
: The first item in the menucenter
: The middle item in the menu (in case of an even number of items, the first item in the second half)end
: The last item in the menuMotivation and Context
The current implementation for the
plz
menu is nearly limited (there are some configuration options but not many). and we need to give the user full control. This change addresses this demand by introducing new features, refining existing systems, and optimizing the menu's behavior.plz
menu configurable via the config file #96How Has This Been Tested?
cargo test --lib
Screensthot
The config file in this example:
Types of Changes
Checklist:
config/halp.toml
file