Skip to content

Adds -A to disable terminal control codes in the output. #73

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

Merged
merged 1 commit into from
Feb 1, 2024

Conversation

xxxserxxx
Copy link
Contributor

  • Have you test the code?
  • Have you check that the existing tests are passing?
  • The destination branch is develop?

This addresses #72
With minimal refactoring, I minimized the changes needed to support parameters more easily, and thereby minimized the amount of code needed to add this feature. These changes are backwards compatible except for error cases; in particular, flags may now appear before or after options, whereas before they could only appear before options. For example, prior to this patch, this would cause an error:

immortalctl -1 stop service

but worse, this would kill all services:

immortalctl stop -1 service

With this patch, arguments and flags are parsed correctly: all flags appear before arguments, which is required for flags.Parse() to work correctly. The positional logic has been largely removed, making adding flags far easier. All of the positional logic has been moved to a single block of 10 lines, making the flow easier to understand, and less fragile. Validation of arguments has been collected and simplified.

This is still not a completely correct use of the flags library, and there remain vestigual anachronisms, such as around line 45, but a fully idiomatic refactoring would be a larger and more disruptive patch.

@nbari
Copy link
Member

nbari commented Feb 1, 2024

Hi @xxxserxxx thanks 👍

@nbari nbari merged commit 0faa583 into immortal:master Feb 1, 2024
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.

2 participants