Title: CLI args/config file refactoring · Issue #897 · scriptcs/scriptcs · GitHub
Open Graph Title: CLI args/config file refactoring · Issue #897 · scriptcs/scriptcs
X Title: CLI args/config file refactoring · Issue #897 · scriptcs/scriptcs
Description: IMO this whole space is currently quite confusing and clunky. After spending time on #896 I started to think about an alternative approach. Here's what I've come up with so far: Splitting of the CLI args into command args and script args...
Open Graph Description: IMO this whole space is currently quite confusing and clunky. After spending time on #896 I started to think about an alternative approach. Here's what I've come up with so far: Splitting of the CL...
X Description: IMO this whole space is currently quite confusing and clunky. After spending time on #896 I started to think about an alternative approach. Here's what I've come up with so far: Splitting o...
Opengraph URL: https://github.com/scriptcs/scriptcs/issues/897
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CLI args/config file refactoring","articleBody":"IMO this whole space is currently quite confusing and clunky. After spending time on https://github.com/scriptcs/scriptcs/pull/896 I started to think about an alternative approach. Here's what I've come up with so far:\n1. Splitting of the CLI args into command args and script args is lifted up to `Program.Main`. I think this can be re-written trivially so it won't be necessary to encapsulate it in a type. It's really a `Program.Main` level operation.\n2. Parsing of the command args into `ScriptCsArgs` is lifted up to `Program.Main`. Normally this is a simple call to `PowerArgs` but since this also has to do some gymnastics regarding `-install` which has two optional parameters, package name and version (something which I think is not natively supported by PowerArgs), this is probably best encapsulated in a `ScriptCsArgsFactory`. If `ScriptCsArgsFactory` throws an exception, `Program.Main` writes the exception message to the console, shows usage and then exits with code 1 (as currently implemented in #896)\n3. If `ScriptCsArgs.Version` or `ScriptCsArgs.Help` are `true`, `Program.Main` either shows the version or displays usage respectively and exits with code 0. This removes the need for `VersionCommand` and `ShowUsageCommand` which, IMO, are not commands, they are just options to show metadata without actually performing a command. This fits the behaviour of other platforms, e.g. node. For more on that, see https://github.com/scriptcs/scriptcs/issues/175#issuecomment-68596753\n4. We read and store the `Config` property from `ScriptCsArgs`\n5. We introduce a new type `ScriptCsConfig` and construct an instance using `ScriptCsArgs`. This can be encapsulated in a `ScriptCsConfigFactory` if required\n\nOnce these steps have been completed, the concept of 'arguments' no longer exists (disregarding the script args which need to be passed all the way through). We only have to think about rehydrating `ScriptCsConfig` instances from the local and global config files and then performing a masking operation: commandLineScriptCsConfig + localScriptCsConfig + globalScriptCsConfig. All properties on `ScriptCsConfig` should be nullable so for each property we take the first non-null value, falling back to a default.\n\nWe then pass the final `ScriptCsConfig` instance, along with the script args, to `CommandFactory` and the rest of the code remains as is.\n","author":{"url":"https://github.com/adamralph","@type":"Person","name":"adamralph"},"datePublished":"2015-01-08T11:07:17Z","url":"https://github.com/scriptcs/scriptcs/issues/897"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:85175182-384e-c935-178c-b7fcd2fa2aee |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A380:157BA1:8FEEEF:C11FD8:6B00432D |
| html-safe-nonce | 047a533adffd0b1b48afb6500f3ff6fc77b0230dd962034eb11737b59a7f6180 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzgwOjE1N0JBMTo4RkVFRUY6QzExRkQ4OjZCMDA0MzJEIiwidmlzaXRvcl9pZCI6IjMzODI3NDI2ODM5NDM0NTM0ODUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a898a6b85c71ae23d49430e32f5fc13f96695d9aa3216e25db9078a1990f2955 |
| hovercard-subject-tag | issue:53739045 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/scriptcs/scriptcs/897/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0861a69d455de953fed1e90e878f236d2c7cfe3d523c966955a38a38928d9566/scriptcs/scriptcs/issues/897 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0861a69d455de953fed1e90e878f236d2c7cfe3d523c966955a38a38928d9566/scriptcs/scriptcs/issues/897 |
| og:image:alt | IMO this whole space is currently quite confusing and clunky. After spending time on #896 I started to think about an alternative approach. Here's what I've come up with so far: Splitting of the CL... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | adamralph |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/scriptcs/scriptcs git https://github.com/scriptcs/scriptcs.git |
| octolytics-dimension-user_id | 3758046 |
| octolytics-dimension-user_login | scriptcs |
| octolytics-dimension-repository_id | 8473240 |
| octolytics-dimension-repository_nwo | scriptcs/scriptcs |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 8473240 |
| octolytics-dimension-repository_network_root_nwo | scriptcs/scriptcs |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width