Skip to content
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 arguments for splits, layout and autosplitter #21

Merged
merged 3 commits into from
Nov 13, 2024

Conversation

flavio-a
Copy link

This PR uses clap to add support for CLI arguments to select splits file, autosplitter file and layout file.

$ livesplit-one --help
Usage: livesplit-one [OPTIONS] [SPLITS]

Arguments:
  [SPLITS]  Split file to open. If not given, takes it from config file (the last one used)

Options:
  -a, --autosplitter <FILE>  Autosplitter file to open. If not given, takes it from config file (the last one used)
  -l, --layout <FILE>        Layout file to open. If not given, takes it from config file (the last one used)
  -h, --help                 Print help
  -V, --version              Print version

A known issue is the following error message when passing any named option:

$ livesplit-one -l test-file
Unknown option -l

Note that the option is processed correctly. This is probably caused by some other cli library embedded in druid that doesn't know anything about options specified by clap. Not sure how to handle this though since I don't know druid. As a side note, the library doesn't complain about the [SPLITS] argument, so a "solution" could be to disable named arguments and only keep [SPLITS].

@AlexKnauth AlexKnauth self-assigned this Nov 11, 2024
@AlexKnauth AlexKnauth added the enhancement New feature or request label Nov 11, 2024
@AlexKnauth
Copy link
Owner

I'm not getting the Unknown option -l error on Mac: the named option arguments seem to be working fine for me there.

@flavio-a
Copy link
Author

I traced the issue to the backend in use for linux, namely gtk-rs-core: this line fetches cli arguments again, that are then parsed by the gio library.

CLI options of gio/gtk
$ ./LiveSplitOne -h
Usage:
  LiveSplitOne [OPTION…]

Help Options:
  -h, --help                 Show help options
  --help-all                 Show all help options
  --help-gapplication        Show GApplication options
  --help-gtk                 Show GTK Options

Application Options:
  --display=DISPLAY          X display to use

Not sure how to go about this, I'll probably check the library docs and google but the code doesn't look promising because it passes them to a function in the ffi module that really looks like a foreign function interface for some C code.

@AlexKnauth
Copy link
Owner

I have tested it on Windows, and the named option arguments work there too, as well as Mac. The CI was failing on Windows so I was a bit worried. I've made a README-only PR which has shown that the Windows CI failures are not your fault, so I'll merge this and figure out the CI failures separately.

@AlexKnauth AlexKnauth merged commit 3be7a5d into AlexKnauth:dev Nov 13, 2024
9 of 11 checks passed
@flavio-a flavio-a deleted the cli-split-file branch November 13, 2024 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants