-
Notifications
You must be signed in to change notification settings - Fork 2
Add settings cli #414
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
Add settings cli #414
Conversation
8b332c0
to
8167fc6
Compare
Here is the help for the tool
I'm not sure the the read flag is very intuitive, I tried to make it clear via the examples + a custom value name to show that you can read a single setting or a group. I have |
env: | ||
LIBCLANG_PATH: ${{ env.LIBCLANG_PATH_WIN }} | ||
if: matrix.os.name == 'windows-2019' | ||
|
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.
This is not uploading any artifact just simply building it. So we should add an artifact upload. The fileio also only uploads artifacts to builds. So when we create a release it still only shows the installers. Maybe you could add this and the fileio binaries to the release stage as well?
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.
Once you think it is groovy you can push a test tag to see if it is working
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.
Ahh good catch. I can do that. Is the intent have one big "swift-toolbox" zip that contains everything, or should we have separate downloads for each tool? Or perhaps we can have both?
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.
I think having separate files makes more sense. Not sure if we want to sign these as well though. Was this done for the old app @silverjam ?
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.
Ahh good catch. I can do that. Is the intent have one big "swift-toolbox" zip that contains everything, or should we have separate downloads for each tool? Or perhaps we can have both?
I think having both would be great. Having it in console installer would mean you automatically have them if you have the console and a separate download for just the CLI tools in the release would allow people on bandwidth constrained environments to grab just the command line tools.
I think having separate files makes more sense. Not sure if we want to sign these as well though. Was this done for the old app @silverjam ?
We should probably sign the command line tools for the "CLI only" zip, or sign the zip file itself
|
||
fn connect(opts: &Opts) -> Result<Arc<SettingsTab>> { | ||
let (reader, writer) = | ||
Connection::discover(opts.device.clone(), opts.conn)?.try_connect(None)?; |
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.
Although I think it is cool to reduce the connection cli to a single input I am worried about having differing approaches for the main app and other bins. I think a good example of this, is that we recently added a shortcut with the "host" input that allows the user to input a host-port pair e.g. "192.168.0.200:55555" which is not handled with your current implementation. As well as, if we do intend to add more connection types in the future, like UDP or others, having to maintain two separate CLIs is less than ideal.
Is there any way that we could merge the subcommand structure into this tool? I think one issue I see is the ability to add additional CLI args after a subcommand. Is there a way to have a subcommand ignore unknown arguments such that they are consumed by the parent bin? I think then it would not be too different from what you have here. What are your thoughts?
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.
I am worried about having differing approaches for the main app and other bins. I think a good example of this, is that we recently added a shortcut with the "host" input that allows the user to input a host-port pair e.g. "192.168.0.200:55555" which is not handled with your current implementation.
Ohh I missed this, the fileio tool also follows this approach as a part of trying to make the tool more scp-like.
Is there a way to have a subcommand ignore unknown arguments such that they are consumed by the parent bin?
Not that I'm aware of, but yeah that's the main motivation as to why I tried to avoid subcommands, having to have the flags in a specific order can be a little confusing. Also without subcommands piksi-settings --help
gives you all the help, rather than having to run it once for each subcommand.
I agree that the behavior/implementation should be shared across all the tools, both for our sake and for the end user. however I'm kind of in the camp that subcommands are not really the correct choice. To me a subcommand implies a different action. For example if we had one parent binary called swift-toolbox
that had commands like swift-toolbox console ...
/swift-toolbox fileio ...
/swift-toolbox settings ...
. Different connection options feels more like a set of mutually exclusive options to me. We could share the behavior with something like
#[derive(Args)]
struct ConnOpts {
#[clap(long, conflicts_with_all = &["serial", "udp"])]
tcp: HostPort,
#[clap(long, conflicts_with_all = &["tcp", "serial"])]
udp: String,
#[clap(long, conflicts_with_all = &["tcp", "udp"])]
serial: PathBuf,
#[clap(long, conflicts_with_all = &["tcp", "udp"])]
baudrate: u32,
#[clap(long, conflicts_with_all = &["tcp", "udp"])]
flow_control: FlowControl,
}
struct HostPort {
host: String,
port: u16,
}
impl FromStr for HostPort {
type Err = ParseIntError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
if let Some(idx) = s.find(":") {
let (host, port) = s.split_at(idx);
Ok(HostPort {
host: host.to_owned(),
port: port[1..].parse()?,
})
} else {
Ok(HostPort {
host: s.to_owned(),
port: 55555,
})
}
}
}
Which I think would work well for the console and piksi-settings, but not so much for fileio. I think if we want to have the "scp-like" interface it'll have to remain a special case.
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.
That sounds reasonable to me. Maybe for now we go ahead with what you have then in a future PR we collapse the main console's cli to unify the behavior with this work.
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.
Sounds good!
.github/workflows/main.yml
Outdated
name: ${{ runner.os }}-fileio | ||
path: | | ||
./target/release/fileio${{ matrix.os.exe_suffix}} | ||
if: matrix.os.name != 'macos-10.15' && github.event_name == 'push' && contains(github.ref, 'refs/tags') |
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.
I do like the idea of having these only build when there is a release to keep CI runtime down but this will only upload the artifact to the Actions page, currently. Youll need to pull down the artifacts below in the "Create Release" stage and then add them to the files section for them to show up on a release.
e753172
to
1571bc0
Compare
33ec2c9
to
c18df70
Compare
FYI just canceling the normal CI because I'm tagging a release on each push anyway 🤷 |
c18df70
to
5011d7b
Compare
5011d7b
to
e0b4262
Compare
1a4a0f8
to
1f95431
Compare
1f95431
to
b9cccd7
Compare
2219e59
to
67e833a
Compare
Finally got one working - https://github.com/swift-nav/swift-toolbox/releases/tag/0.17.0-test3 Some of the other assets aren't there because I removed a bunch of stuff while I was iterating on the workflow |
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.
LGTM we should do one final test release once you have uncommented everything as a sanity check before merging
🥳 https://github.com/swift-nav/swift-toolbox/releases/tag/0.17.0-test5 |
Hmm not sure why it thinks the CI is still going, looks like both the regular CI and the tag push finished. @john-michaelburke you might need to use your admin privileges to merge without the checks |
Differs a bit from the python tool, namely the save command can be combined with commands that write to the device, you can write multiple values at once, and you can read a single setting or a group.