Skip to content

Invalid CLI commands should return non-zero exit code #2552

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

Merged
merged 2 commits into from
Mar 14, 2025

Conversation

FranjoMindek
Copy link
Contributor

Add exitFailure to invalid wasp-cli usages

As far as I can see it works.

➜  waspc git:(bf/franjo/wasp-cli-exit-code) ✗ cabal run wasp-cli asdasdasdasdasd
USAGE
  wasp <command> [command-args]
...

➜  waspc git:(bf/franjo/wasp-cli-exit-code) ✗ echo $?
1
➜  waspc git:(bf/franjo/wasp-cli-exit-code) ✗ cabal run wasp-cli db migrate
USAGE
  wasp db <command> [command-args]
...

➜  waspc git:(bf/franjo/wasp-cli-exit-code) ✗ echo $?
1

Side note:
I think Main.hs is a bit messy currently with the file doing too much work.
There is this note:

-- TODO: maybe extract to a separate module, e.g. DbCli.hs?
dbCli :: [String] -> IO ()

Same should probably be done for AI part.

Fixes #2491

@FranjoMindek FranjoMindek changed the title Bugfix: invalid commands end up in exitFailure Invalid CLI commands should return non-zero exit code Mar 14, 2025
Copy link
Member

@Martinsos Martinsos left a comment

Choose a reason for hiding this comment

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

LGTM!
Tiny hint: instead of doing

do
  printUsage
  exitFailure

you can do it in one line

printUsage >> exitFailure

You don't have to do, if you find the first one more readable, just wanted to share the tip.

@FranjoMindek
Copy link
Contributor Author

Thanks for the tip.
Still learning haskell, I'll change it.

@Martinsos
Copy link
Member

Thanks for the tip. Still learning haskell, I'll change it.

I know which is why I shared it, but also feel free to keep it as it was originally if you like that better / find it more readable!

@FranjoMindek FranjoMindek merged commit bd18aa9 into main Mar 14, 2025
6 checks passed
@FranjoMindek FranjoMindek deleted the bf/franjo/wasp-cli-exit-code branch March 14, 2025 17:02
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.

Invalid wasp commands return a zero exit code
2 participants