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

Adds Support for Command-Line on Windows #3699

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

niwamo
Copy link

@niwamo niwamo commented Aug 26, 2024

Description

Adds support for command-line usage / command-line arguments on Windows.

Closes #2118

Approach

I assume this wasn't done previously because Windows apps can be console apps or windows apps, but not both. That leaves two options with a single flameshot executable:

  1. A GUI app that respects CLI arguments but never returns any text to console
  2. A console app that always pops up a console window, even when started with a double-click

There are some workarounds to mitigate the inconveniences of these approaches, but ultimately, the best solution is two executables.

Good discussions on this topic can be found on Stack Overflow here and here.

This commit adds the windows-cli.cpp source, which compiles into flameshot-cli.exe when built on Windows. It is a minimal wrapper around flameshot.exe but ensures that all stdout is captured and output to the console.

Code Changes

  • The preprocessor macro that prevented arg parsing on Windows has been removed from main.cpp
  • windows-cli.cpp has been added as the source for flameshot-cli.exe
  • The flameshot-cli target has been added to cmake (only when building on Windows)
  • README updates

README Updates

Usage on Windows

On Windows, flameshot.exe will behave as expected for all supported command-line arguments, but it will not output any text to the console. This is problematic if, for example, you are running flameshot.exe -h.

If you require console output, run flameshot-cli.exe instead.

- removes the preprocessor macro that prevented arg
  parsing on Windows
- adds windows-cli.cpp as src for a wrapper exe
- adds flameshot-cli target into cmake when building
  on Windows
- updates README
@niwamo
Copy link
Author

niwamo commented Sep 5, 2024

@mmahmoudian hi, looks like you're the most active maintainer... would you mind giving this a review?

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.

Implement the same CLI args in Windows build
1 participant