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 option --dry-run #1

Closed
andreasabel opened this issue Dec 30, 2020 · 12 comments
Closed

Add option --dry-run #1

andreasabel opened this issue Dec 30, 2020 · 12 comments

Comments

@andreasabel
Copy link

Thanks for this tool! Tried it today in dear need for some diskspace.
I ran

$ stack-clean-old snapshots remove-earlier-minor
4 snapshots removed for 8.6.3
1 snapshots removed for 8.6.4
2 snapshots removed for 8.8.2
33 snapshots removed for 8.10.2

I think I intended to keep 8.10.2 as 8.10.3 is still brand-new...
No big problem, I suppose, but I think an option --dry-run would be terribly useful to see what will happen and if this is what one intends to happen.

Btw, I discovered your tool here: commercialhaskell/stack#133 (comment)

@juhp
Copy link
Owner

juhp commented Dec 31, 2020

Which version are you using?

$ stack-clean-old --version
0.2.1
$ stack-clean-old snapshots remove-earlier-minor --dryrun
80 snapshots removed for 8.10.2

Maybe --dry-run is more common? You can also use -n.

If you wanted to keep 8.10.2, you could do: $ stack-clean-old snapshots remove-earlier-minor 8.10.2.

Thanks for the feedback.

@andreasabel
Copy link
Author

I was using 0.2.1

$ stack-clean-old --version
0.2.1

Oops, I didn't know that a dry-run option was already implemented.

Maybe all that is needed to make it more discoverable. With my attempts to get help, I didn't see it:

$ stack-clean-old --help
Stack clean up tool

Usage: stack-clean-old [--version] COMMAND
  Cleans away old stack-work builds (and pending: stack snapshots) to recover
  diskspace.

Available options:
  -h,--help                Show this help text
  --version                Show version

Available commands:
  project                  Commands for project .stack-work builds
  snapshots                Commands for ~/.stack/snapshots
  ghc                      Commands on stack's ghc compiler installations

$ stack-clean-old snapshots --help
Usage: stack-clean-old snapshots COMMAND
  Commands for ~/.stack/snapshots

Available options:
  -h,--help                Show this help text

Available commands:
  size                     Total size of all stack build snapshots
  list                     List build snapshots per ghc version
  remove-version           Remove build snapshots for a ghc version
  remove-earlier-minor     Remove build snapshots for previous ghc minor
                           versions

If one knows what to look for and tries really hard, one can see it:

$ stack-clean-old snapshots remove-earlier-minor --help
Usage: stack-clean-old snapshots remove-earlier-minor [-n|--dryrun] [GHCVER]
  Remove build snapshots for previous ghc minor versions

Available options:
  -n,--dryrun              Show what would be done, without removing
  -h,--help                Show this help text

But this is the first time in my life that I had to invoke

command subcommand subsubcommand --help

to see an option. I am used to

command --help

and for fat tools like git

command subcommand --help

but I haven't encountered deeper nesting yet.

Maybe the option --dryrun could be moved a bit further up, even if it has null effect on print-only commands like list and size? Wouldn't hurt, I suppose.

Also, I'd agree that --dry-run with a dash is more common.

juhp added a commit that referenced this issue Jan 4, 2021
juhp added a commit that referenced this issue Jan 4, 2021
- If in a project by default we act on it otherwise .stack/
- Can be overriden with options (-p,-s,-c,-g)

Based on feedback by @andreasabel in #1 and
also from u/simonmic in https://www.reddit.com/r/haskell/comments/knn5yt/stackcleanold_cli_tool_to_recover_diskspace/ghtl9wy/
@juhp
Copy link
Owner

juhp commented Jan 4, 2021

If you want to try the reworked subcommands in HEAD and have any feedback, that would be nice.

@andreasabel
Copy link
Author

Thanks for reworking the command structure! Here is a little feedback...

I tried HEAD (0.3) a bit, but didn't have to remove anything at this moment.

$ stack-clean-old remove 8.0.2 -n
stack-clean-old: stack ghc compiler version 8.0.2 not found

In my case, there isn't a ghc installation, but there are snapshots at 8.0.2:

$ stack-clean-old list
ghc-8.2.2
ghc-8.4.4
...
162M  7.10.3 (2 dirs)
388M  8.0.2  (5 dirs)
210M  8.2.2  (1 dirs)
576M  8.4.4  (4 dirs)
...

So I suppose the message stack ghc compiler version 8.0.2 not found could be complemented by a message saying snapshots would be removed.
Assuming that -g is the default, of course.
Should it say so in the help text?

$ stack-clean-old remove --help
Usage: stack-clean-old remove [-n|--dry-run] 
                              [(-p|--project) | (-s|--snapshots) | 
                                (-c|--compilers) | (-g|--ghc)] GHCVER
  Remove for a ghc version

Available options:
  -n,--dry-run             Show what would be done, without removing
  -p,--project             Act on current project's .stack-work/
  -s,--snapshots           Act on ~/.stack/snapshots/
  -c,--compilers           Act on ~/.stack/programs/
  -g,--ghc                 Act on both ~/.stack/{programs,snapshots}/
  -h,--help                Show this help text

Now, trying with -s:

$ stack-clean-old remove 8.0.2 -s -n
5 snapshots removed for 8.0.2

My heart skipped a beat since I wasn't sure if things had been removed. The message says so, maybe it would be better to say "would be removed" if option -n is given.

@juhp
Copy link
Owner

juhp commented Jan 5, 2021

Thank you, basically that is a bug: it gives up when finding no compiler...

@juhp
Copy link
Owner

juhp commented Jan 5, 2021

(Also not sure if --snapshots and --compilers are overkill, maybe what I misnamed --ghc is enough, hm?)

juhp added a commit that referenced this issue Jan 5, 2021
juhp added a commit that referenced this issue Jan 5, 2021
allows --ghc to remove snapshots without compiler
@juhp
Copy link
Owner

juhp commented Jan 5, 2021

Thank you, basically that is a bug: it gives up when finding no compiler...

Should be fixed now

@andreasabel
Copy link
Author

... In my case, there isn't a ghc installation, but there are snapshots at 8.0.2: ...

I confirm that this is fixed now:

$ stack-clean-old remove 8.0.2 -n
stack ghc compiler version 8.0.2 not found
5 snapshots would be removed for 8.0.2

... -g is the default ... Should it say so in the help text?

Does now:

  -g,--ghc                 Act on both ~/.stack/{programs,snapshots}/ [default
                           outside project dir]

Thanks!

The name choice --ghc is indeed surprising, what about --all?

@juhp
Copy link
Owner

juhp commented Jan 5, 2021

Right, I went with --global for now

Thanks for all the constructive feedback and testing :-)

@juhp
Copy link
Owner

juhp commented Jan 5, 2021

I think we can close this, but if you notice anything directly related you can still comment or open a new issue, thanks!

@andreasabel
Copy link
Author

Thanks for the prompt addressing of this issue!

@juhp
Copy link
Owner

juhp commented Jan 8, 2021

I finally released 0.3 btw

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

No branches or pull requests

2 participants