pashi
pashi copied to clipboard
Add command line option to set & view default options
At present the only way to configure PasHi is to create a file named config in PasHi's data directory at %APPDATA%\DelphiDabbler\PasHi.
It would be useful to be able to write configuration information to the config file from the command line.
A command line option could be added to do this that is similar to git config: something like pashi --options.
For example
--options set command=paramor--options set commandwould write the given command to the config file, with any required parameter. Setting the same option twice would replace any parameter in the config file. For a parameter-less option this would be a no-op.--options check commandwould indicate if a command was present in the config file or not. For a command with a parameter the parameter would be displayed.--options showwould display all current options in the config file.--options delete commandwould remove the given command from the config file. An error would be reported if the command wasn't present.--options purgewould remove all options from the config file (or delete the file).
It would be useful if commands being set could be validated.
The command should also prevent any blacklisted commands from being written to the config file. Blacklisted commands (i.e. those that aren't valid in the config file) should be help and options.
Could also add --options edit to display config file in a text editor.
Considering using --config rather than --options as main command.
Another possibility is to use several related commands to reduce number of parameters. Thus:
| Original command | Alternative command |
|---|---|
--options set command=param |
--config-set command=param |
--options set command |
--config-set command |
--options check command |
--config-find command |
--options show |
--config-show |
--options delete command |
--config-delete command |
--options purge |
--config-purge |
--options edit |
--config-edit |
May need to experiment with both approaches.
Probably adding this to v3 now.
Further discussion of this and other v3 development ideas to continue in the v3 Development Project
Consider issue #23 before starting work on this.
Further discussion of this and other v3 development ideas to continue in the v3 Development Project
The project noted above simply references the v3-design document on Google Drive, which can't be edited. So I've copied what it says below.
Configuration Execution Context
This context is used to update the program's config file and to display both all and current settings.
Activated by the --config command being the first entry on the command line.
Requires access to the command parser to check validity of the name of any command and it's parameter that is requested to be written to the config file.
The command takes one of the following forms:
--config--config view--config status <command>--config set <command> <parameters>--config delete <command>--config clear--config clear force
[where] <command> must be the name of a valid config file command [and] <parameters> must be zero or more space separated parameters that are valid for <command>
The purpose of the different --config command forms is:
- Displays brief help on using the command
- Displays a sorted list of all commands in the config file along with any associated parameters
- Checks whether
<command>is in the config file and displays its parameters, if any. - Writes
<command>and any given<parameters>to the config file. - Deletes
<command>from the config file. - Clears the contents of the config file. Prompts for confirmation.
- Clears the contents of the config file without prompting for permission.
Notice that --options has changed to --config and that the idea of multiple commands with different names has been dropped.
Further discussion will take the content of this comment as a starting point.
Consider issue #23 before starting work on this.
Instead of having a separate --use-config-file option --config could be extended to have a use sub-command that sets the config file to use:
--config use <filename>to set or create the config file to use in all further calls to--config.--config use -to restore the default config file.
This command would adopt the suggestion in issue #23 to record the current config file name in a file stored in a special (hidden?) .pashi directory. Users will be forbidden from using this directory for custom config or any custom CSS files.
Consider issue #23 before starting work on this.
Instead of having a separate
--use-config-fileoption--configcould be extended to have ausesub-command
Adopting this suggestion means that issue #23 can be closed and wrapped into this issue.
To summarise, the single command --config will be used, with the following parameters:
| Parameter | Description |
|---|---|
view or list |
Displays a sorted list of all the command's in the config file. |
status <command> |
Checks whether <command> is in the config file and displays its parameters, if any. |
set <command> <parameters> |
Writes <command> and any given <parameters> to the config file. |
delete <command> |
Deletes <command> from the config file. |
clear [force] |
Clears the contents of the config file. Prompts for confirmation, unless the optional force flag is present. |
copy <filename> [force] |
Copy content of current config file to <filename>, prompting for confirmation if <filename> exists, unless the optional force flag is present. |
copy - [force] |
Copy content of current config file to default config file, prompting for confirmation if default config file exists, unless the optional force flag is present. |
use <filename> |
Set or create the config file <filename> to be used in all further calls to --config. |
use - |
Restore the default config file for use in all further calls to --config. |
none or help |
Displays brief help on using the command. |
The current config file to use would be recorded in file named config-use in the %AppData%\DelphiDabbler\PasHi\.pashi directory. If this file is missing the default config file is used.
User config files are stored in %AppData%\DelphiDabbler\PasHi\.pashi\user-cfg\ directory, whereas the default config file is stored in %AppData%\DelphiDabbler\PasHi\.pashi\default-cfg file.