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

Document the default behavior when --watch flag is not present #307

Open
jhrcek opened this issue Jul 25, 2024 · 2 comments
Open

Document the default behavior when --watch flag is not present #307

jhrcek opened this issue Jul 25, 2024 · 2 comments
Labels
linear Created by Linear-GitHub Sync

Comments

@jhrcek
Copy link

jhrcek commented Jul 25, 2024

Describe the feature you’d like to be implemented

It would be nice to mention (maybe in --help, but definitely in docs) what exactly is being watched when --watch flag is not specified.

Is cabal file included in the watching by default? It seems to me that there are no reloads on cabal file changes (in which case this is a bug report). Is it all .hs files found in current directory?

List alternatives to the feature and their pros and cons

No response

Additional context

Thank you for opensourcing this great tool, I switched my project to it from ghcid and I'm excited it fixes many issues that I had with ghcid

@github-actions github-actions bot added the linear Created by Linear-GitHub Sync label Jul 25, 2024
@9999years
Copy link
Member

Thanks for the ticket!

The short answer is that the default value is src. It's pretty unsophisticated. I thought I had a note explaining this somewhere but apparently I do not. Do you have somewhere you think this information should live? (Where did you look for it before you realized it wasn't listed?) I might create a new section in the user manual for it.

If a file argument is given (ghciwatch Foo.hs), the command executed is ghci Foo.hs. If neither a file argument nor --command are given, the command is cabal repl.

ghciwatch/src/ghci/mod.rs

Lines 132 to 139 in 56db4fb

// TODO: implement fancier default command
// See: https://github.com/ndmitchell/ghcid/blob/e2852979aa644c8fed92d46ab529d2c6c1c62b59/src/Ghcid.hs#L142-L171
let command = match (&opts.file, &opts.command) {
(Some(file), None) => ClonableCommand::new("ghci").arg(file.relative()),
(None, Some(command)) => command.clone(),
(None, None) => ClonableCommand::new("cabal").arg("repl"),
(Some(_), Some(_)) => unreachable!(),
};

I also have a long-standing TODO to copy some of ghcid's logic for constructing a default command, which is listed here:

https://github.com/ndmitchell/ghcid/blob/e2852979aa644c8fed92d46ab529d2c6c1c62b59/src/Ghcid.hs#L142-L171

@jhrcek
Copy link
Author

jhrcek commented Jul 26, 2024

Do you have somewhere you think this information should live?

Good question.
Skimming the docs again I see it's actually mentioned in passing in the first example:
https://mercurytechnologies.github.io/ghciwatch/cli.html#examples
"Load cabal v2-repl and watch for changes in src:"

I would expand that to "watch for changes to *.hs files in src directory or any of its subdirectories (recursively)" (or whatever is actually true)

Originally I was looking for it under --watch flag's documentation
https://mercurytechnologies.github.io/ghciwatch/cli.html#--watch
maybe because I'm used to optparse-applicative showing the defaults as part of the help message for each flag, e.g. it could be added as last sentence there..

--watch <PATH>
    A path to watch for changes.

    Directories are watched recursively. Can be given multiple times.

    **If not provided, the default behavior is as if `--watch src` was provided.**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear Created by Linear-GitHub Sync
Projects
None yet
Development

No branches or pull requests

2 participants