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

Add --help and --new-window flag and fix --version flag #6455

Open
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

Zander671
Copy link

Add --help and --new-window flag and fix --version flag

Pull Request Type

  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

#4446

Description

This contains three commits. The first adds a --new-window argument. This argument causes a new window to be opened in an existing instance. If there is no existing instance, it creates a new instance. The second fixes the --version flag that got broken by #2606. The third adds a --help flag.

Screenshots

screenshot-2024-12-25--21-12-33
screenshot-2024-12-25--21-12-46

Testing

The --help and --version flags were (hopefully) trivial to test. Their output can be seen above. The scope of the modifications required for the --new-window flag is also fairly small. I tested starting freetube both with and without the --new-window flag and both with and without a url. It worked in all four cases.

Desktop

  • OS: ArchLinux
  • OS Version: 6.12.4-zen1-1-zen
  • FreeTube version: v0.22.1

Additional context

@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Dec 26, 2024
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) December 26, 2024 05:42
Copy link
Collaborator

@kommunarr kommunarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working great for me!

suggestion (non-blocking): A non-recognized argument error might be a good idea for preventing an accidental app load from a typo if we don't mind slightly expanding the scope. It could be frustrating to type -version and accidentally launch a window. E.g., Here's a similar error from nano for reference:

nano: unrecognized option '--potato'
Type 'nano -h' for a list of available options.

@Zander671
Copy link
Author

The problem (at least on Linux) with validating arguments in this way is that Electron parses arguments like --enable-features=UseOzonePlatform and --ozone-platform=wayland. While it would be possible to check against a list of all Electron's supported flags, this seems like it might be hard to maintain as new flags are added (unless there is a way to get all supported arguments programmatically, but a quick search yielded no results).

kommunarr
kommunarr previously approved these changes Dec 28, 2024
Copy link
Collaborator

@kommunarr kommunarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I completely forgot about that. Here's how Codium handles this for a more similar example, where they show a warning but still continue to launch. Will approve now, as I'm not sure of not a fan of the effort to get this list of known options:

Warning: 'potato' is not in the list of known options, but still passed to Electron/Chromium.

Copy link
Member

@absidue absidue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't got around to testing this yet, but at least from the code it looks like --version and --help will only be usable if FreeTube is not currently running.

src/main/index.js Outdated Show resolved Hide resolved
Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
auto-merge was automatically disabled January 1, 2025 22:04

Head branch was pushed to by a user without write access

@Zander671 Zander671 dismissed stale reviews from ChunkyProgrammer and kommunarr via e0f0d9a January 1, 2025 22:04
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) January 1, 2025 22:04
@Zander671
Copy link
Author

I haven't got around to testing this yet, but at least from the code it looks like --version and --help will only be usable if FreeTube is not currently running.

FreeTube calls app.requestSingleInstanceLock() and checks the return value in runApp(). The --help and --version flags are checked before runApp() ever gets called. This seems to work fine in my testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: waiting for review For PRs that are complete, tested, and ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants