Add command line completions for installed and available versions.
When running ghcup set ghc
and pressing tab, it's great to be able
to autocomplete the currently installed GHCs we have available.
I've added a basic optparse applicative completer for install, rm, and set commands which shows tags and versions. For installation, all are shown, while for remove and set, only those installed are.
Merge request reports
Activity
added 1 commit
- 72965f0c - Add command line completions for installed and available versions.
added 1 commit
- d6fa61e2 - Add command line completions for installed and available versions.
808 808 % _head 809 809 ) 810 810 dls 811 812 813 -- Gathering monoidal values 814 traverseFold :: (Foldable t, Applicative m, Monoid b) => (a -> m b) -> t a -> m b 815 traverseFold f = foldl (\mb a -> (<>) <$> mb <*> f a) (pure mempty) 816 817 -- | Gathering monoidal values 818 forFold :: (Foldable t, Applicative m, Monoid b) => t a -> (a -> m b) -> m b 819 forFold = flip traverseFold traverseFold
only inlines if given one parameter. WhileforFold
always inlines it will expand toflip traverseFold
, notflip foldl (\mb a -> (<>) <$> mb <*> f a) (pure mempty)
, making further optimizations/fusion harder (because we don't pass an argument totraverseFold
).To make sure
forFold
properly inlines, we can do:forFold = \t -> \f -> traverseFold f t
changed milestone to %0.1.13
I have also been considering disallowing the completion from making internet calls and just using the cache.
It's a simple change of exposing
readFromCache
and using it instead ofgetDownloadsF
. It feels like it makes things snappier; but maybe I should only do it for "set" and not "install".I have also been considering disallowing the completion from making internet calls and just using the cache.
Hmm, I'm not sure how ppl generally think about this. I personally have no strong opinion, but it could be considered annoying/intrusive.
Thinking about it... I think
readFromCache
is the right way to go, but we also have to account for this to fail (e.g. on very first use, when nothing has been downloaded yet).Edited by Julian Ospaldadded 1 commit
- d42e718f - Just use the cache for commands which refer to locally stored objects.
added 1 commit
- e1b1832f - Just use the cache for commands which refer to locally stored objects.
769 toolVersionArgument = 770 argument (eitherReader toolVersionEither) (metavar "VERSION|TAG") 771 768 toolVersionArgument :: Bool -> Maybe ListCriteria -> Maybe Tool -> Parser ToolVersion 769 toolVersionArgument networkSensitive criteria tool = 770 argument (eitherReader toolVersionEither) (metavar "VERSION|TAG" <> completer tagCompleter <> foldMap (completer . versionCompleter networkSensitive criteria) tool) 771 772 773 versionArgument :: Bool -> Maybe ListCriteria -> Maybe Tool -> Parser GHCTargetVersion 774 versionArgument networkSensitive criteria tool = argument (eitherReader tVersionEither) (metavar "VERSION" <> foldMap (completer . versionCompleter networkSensitive criteria) tool) 775 776 777 tagCompleter :: Completer 778 tagCompleter = 779 listCompleter [ 780 "recommended", "latest"