-
Notifications
You must be signed in to change notification settings - Fork 3
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
CLI improvements proposal: positional argument #65
Conversation
cc5d0f6
to
618f047
Compare
b1813a4
to
0f8a43e
Compare
5a8c694
to
b93c2e5
Compare
) | ||
|
||
flags.StringVar(&config.AppID, | ||
devices.StringVar(&config.AppID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --app-id
flag was removed from application
command of ttnv{2,3}
sources since there was no use case for it.
Example:
ttn-lw-migrate ttnv3 application --app-id 'my-app'
If the tool was called like this without an argument it would expect to receive Application IDs from stdin
so the flag would be ignored and the tool would 'hang unexpectedly' (waiting).
Since f33a68b the argument always overrides the flag. This combination makes the flag redundant or even confusing for the application
command in those sources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this flag magic really necessary? Why don't we have commands per source with their own flag sets?
Also I see some exotic use of switch/case while this is what simple if/else statements seem to be made for.
@happyRip I think this actually may be better than our current hack. We would need to generate dynamically an |
CHANGELOG.md
Outdated
@@ -8,24 +8,31 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | |||
|
|||
### Added | |||
|
|||
- Added `--ttnv3.no-session` and `--ttnv3.delete-source-device` flags | |||
- positional `source` argument |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upper case first letter and dot at the end.
CHANGELOG.md
Outdated
|
||
### Changed | ||
|
||
### Fixed | ||
- depreciated `--source` flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upper case first letter, deprecated
and dot at the end.
CHANGELOG.md
Outdated
|
||
### Removed | ||
|
||
- `--app-id` flag for `application` command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dot at the end. Same below.
return err | ||
} | ||
|
||
// deleteSourceDevice not allowed when dryRun |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DeleteSourceDevice is not allowed during a dry run
.
6750f9c
to
bc29d66
Compare
bc29d66
to
af21b65
Compare
af21b65
to
66d0239
Compare
What is the status here - is this blocked on anything ? Does it need any technical decision ? |
Subcommands approach was merged, so this PR can be closed. |
Summary
Closes #56
Changes
Add an optional positional
source
argument (pkg/arg
)Print only source-related flags with those commands
ttnv3
flags; to be followed with other sourcesSplit
application
anddevices
commands FlagSetsImproved
ttnv3
config by utilising flags that save value to variables directlyTesting
local testing
Regressions
I do not expect any.
Notes for Reviewers
If we were planning to add more commands in the future, FlagSet splitting could be upgraded to a more sophisticated solution. Currently it's pretty simple.
It was suggested to use generated commands like
tts-devices
ETC, but I wanted to propose this solution which seems to work well and is pretty simpleWhen
pflag
is used to set ActiveSource the value is set after initialisation, so the flags cannot be separated easily (duringFlagSet()
function call)Checklist
CHANGELOG.md
.