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

Set default run #8547

Open
pedrogomes29 opened this issue Oct 21, 2022 · 5 comments
Open

Set default run #8547

pedrogomes29 opened this issue Oct 21, 2022 · 5 comments

Comments

@pedrogomes29
Copy link

I have a test-suite and an executable, and I want to automatically run the executable when I type cabal run. However, it says that the run command is for running a single executable at once (since it doesn't know whether to run the test or the exe). How do I make cabal ignore test suites when executing cabal run?

@pedrogomes29
Copy link
Author

I don't want to disable tests, I want to execute tests when I type cabal test and execute the executable when I type cabal run

@ffaf1
Copy link
Collaborator

ffaf1 commented Oct 21, 2022

Hello Pedro, can you tell us why cabal run exectutable-name does not fit your workflow?

@mouse07410
Copy link
Collaborator

I can answer this - because (a) one might not remember what exact names executables in the project have, (b) for a simple project (one "target" exe, one "test" exe) it's silly inconvenient for the user to supply info that Cabal ought to know by itself.

I can envision difficulties with projects that build several executables (and/or several test-binaries).

@ffaf1
Copy link
Collaborator

ffaf1 commented Oct 21, 2022

for (b), cabal is doing the right thing already, am I wrong?

# `.cabal` file with one exe, one testsuite
f@mkiii:~/francesco/progetti/progr/lentill$ cabal run             # no target specified here
Warning: this is a debug build of cabal-install with assertions enabled.
Up to date
Missing: PATH...

Usage: lentil [-h|--help] PATH... [-x PATH] [-f TYPE]
              [-t EXPR | -T EXPR | -p EXPR | -P EXPR | -d EXPR | -D EXPR]
              [-a ALIAS] [-w FLAGWORD] [--output FILE] [-v|--version]

(a) I am not really sure. If you do not remember the name it is because there are multiple executables, and if there are multiple executables you should specify one.

@mouse07410
Copy link
Collaborator

Alas, no.

For (a), the name of a sole executable could be <project_name>, or <project_name-exe>, or something altogether different. While looking it up should be as simple as browsing the <project_name>.cabal file (or doing cabal --list-bins), it's an extra and unnecessary effort.

Fur (b), we claim that the "right thing to do" when only one executable was built, would be to execute it upon command cabal run, as there's no ambiguity.

It's a small thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants