-
Notifications
You must be signed in to change notification settings - Fork 847
Introduce new sub command ls #3252
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
Conversation
Have to do this to avoid travis CI failures
|
@harendra-kumar Thanks. I didn't know the existence of the other issue. I modeled the interface loosely around nvm. Let me know if you feel there should be any specific changes to the interface. |
|
I have the following suggestions:
ping @mgsloan |
|
This would be very useful if I could pipe the output through |
Seems that change was merged! Nice one. @psibi, any movement on getting this mergeable? What's left to do? |
|
So finally got some time to work on this! Some updates:
This is the current help message: |
|
A few thoughts on the UI/UX: Personally, I'd prefer a more descriptive name than Also, how about simplifying the UI a bit by making the I guess it would be nice to get some integration for custom/extended snapshots but I haven't used them and have no idea how to achieve that. |
|
@sjakobi the In fact the I like the idea of making |
Thanks for clarifying, @harendra-kumar! I should have read the comments here more thoroughly. |
src/Stack/Ls.hs
Outdated
| [] -> return () | ||
| xs -> | ||
| let snaps = BC.concat $ L.map displaySingleSnap xs | ||
| in pageByteString snaps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an issue with always using the pager, which is that someone might want to consume the output programmatically via stdout. Perhaps do isStdoutTerminal <- view terminalL and if true, then run the pager? If false, then assume it's running in a script, and instead send to stdout.
May also be worth considering representing this stuff as Text not ByteString. In a few places above pack is used to go from String to ByteString. I think this is fine, because the Strings will always be ASCII, but it would break on unicode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, will do this.
| "Print out handy path information" | ||
| pathCmd | ||
| Stack.Path.pathParser | ||
| addCommand' "ls" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be list-snapshots. There is already some precedent here, with list-dependencies.
How about the default for stack list-snapshots first displaying the remote snapshots, and then displaying the local snapshots. Then, can have stack list-snapshots remote and stack list-snapshots local, particularly useful for when a script wants to access this info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgsloan As mentioned by Harendra here, ls is the umberlla command. dependencies will be made to work under this interface ( I can work on this - after the PR get's merged)
How about the default for stack list-snapshots first displaying the remote snapshots, and then displaying the local snapshots. Then, can have stack list-snapshots remote and stack list-snapshots local, particularly useful for when a script wants to access this info.
Display remote snapshots involves an HTTP call and I want to avoid doing that by default. By default, I'm planning to show the local snapshots and then have different options for displaying each of them. Let me know if you think otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I had not read those comments recently. Ok, I am fine with doing it that way.
|
LGTM for the most part, just a couple comments. Thanks for working on this, it's good stuff! Sorry for letting it languish so long! In the future it'd be cool to open an issue first so design can be discussed, but no biggie. This way we can hopefully end up with an initial implementation that's closer to what will be merged. |
|
@mgsloan Left some comments on your review.
Yeah, I totally agree. And I guess that's the reason it has been pending for quite some time. |
Yes, part of it! My initial reaction was "Why does 'stack ls' have such a generic name?" - I should have been more open to a feature PR, but also would be good to discuss first. It became more likely to procrastinate doing review once it was already late. Going to try to avoid that cycle in the future! I've switched to firefox so hopefully the "my browser window with all the stack issue tabs didn't get ressurrected" problem won't happen anymore. Actually, I'm not sure if the discuss first approach is always needed, or even whether it is a good thing to require / recommend. After all, necessity is the mother of invention, so if you solve a problem for yourself by adding a feature, it is probably better to do that than to delay on discussion. Hmm, tradeoffs! Maybe a dual approach. Open an issue like "I am working on thing X, it is going to look like this:" and then keep working on it while discussion happens. |
Now the interface is similar to previous commands but we have done some minor changes: If a user gives just `stack ls snapshots`, then by default we show the local snapshots available. Also based on @mgsloan's input, I don't always use pager now. Also a new convienence API has been added to `PagerEditor.hs` which exports a function `pageText`. We use that in our module to pass `Text` content to pager. (We were using ByteString previously).
|
Some updates about the previous commit: The If a user gives just Also based on @mgsloan's input, I don't always use a pager now. Also a The latest commits addresses all the comments above. So, there is no pending |
|
LGTM, yep just some hlint errors to resolve |
ChangeLog.md
Outdated
| * A new sub command `ls` has been introduced to stack to view | ||
| local and remote snapshots present in the system. Use `stack ls | ||
| snapshots --help` to get more details about it. | ||
| * `pageText` function introduced in `System.Process.PagerEditor` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation details shouldn't go in the changelog, since stack isn't typically used as a library. All of stack's APIs should be considered to be "internal", in other words they are subject to change even between minor versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgsloan Fixed in the latest push.
|
Good work! Just the one tweak to the changelog and this can be merged. I like the style of having additive commits while working on a PR, makes reviewing easier. However, once ready for merge, it can be nice to squash it down to a single commit. Not a big deal, I'd merge it either way. |
|
The build failure is happening in Travis because of timeout issue and is not related to the code. I think somebody from the Stack team has to restart the particular failing build. |
The main idea here is to not pollute the history with commits that do not add a logically significant change but are just cleanup or random change kind of stuff. So I guess it should be ok to squash it into multiple commits as long as you know that those are logically independent significant steps. Also, we have added an umbrella Nice work @psibi! |
|
@harendra-kumar The github interface allows the committers to squash and merge the commit of this PR. So, I'm leaving the option to the committers. :-) I can squash and merge myself, if others also feel so. I plan to raise other issues soon. |
|
Nice one @psibi! Should we open a ticket for adding documentation too? |
|
Thanks for your hard work @psibi ! Other tickets and PRs certainly encouraged. |
Please include the following checklist in your PR:
So this patch introduces a new subcommand named ls. Basic usage info:
One can view the remote snapshots like this:
$ stack ls remoteIf you want to just filter out the lts views, then:
$ stack ls -l remoteOr if you want to just view the nightly ones, then:
$ stack ls -n remoteYou can also view your locally stored snapshots:
You can apply similar filtering as above:
Note that the above PR will work only when the new stackage server code is deployed. Right now all the testing has been done locally.