Closed chrisdone closed 9 years ago
Bikeshedding: rather than setup
, I think init
is more common terminology for such an operation. (e.g. git, yesod, cabal).
If a cabal.config
file already exists, what do you think this operation should do?
I wasn't committed to the setup
name, init
does make sense, let's go with that.
If it already exists we could ignore it which would make the command somewhat idempotent a la cabal.
@chrisdone I've added stackage-init
, with a sketch of the implementation. It doesn't make it past the parser, though. If you have a spare moment, take a look and perhaps you can help me figure out why.
https://github.com/fpco/stackage-cli/blob/master/stackage-init/main/Main.hs
What does it do? No output?
It outputs a "usage" message. main
never got past the simpleOptions
line, because optparse-applicative decided that the program was not invoked correctly. I've temporarily changed it to not use optparse-applicative, and it works as expected.
I fixed that problem. You should be able to complete this now unimpeded by the optparse stuff.
Current behaviour:
$ stackage --help
Run stackage commands
Usage: stackage [--help] [--version] [--summary] COMMAND
Run stackage commands
Available options:
--help Show this help text
--version Show version
--summary Show program summary
Available commands:
stackage Upgrade stackage stuff
stackage Upgrade stackage stuff
stackage Upgrade stackage stuff
$ stackage init --help
Initializes cabal.config
Usage: stackage-init [--help] [--version] [--summary] [SNAPSHOT]
Initializes cabal.config
Available options:
--help Show this help text
--version Show version
--summary Show program summary
$ stackage init
$ stackage init
Warning: cabal.config already exists
No action taken
stackage: StackagePluginExitFailure 1
☺
Now supports any string that correctly fits between http://stackage.org/
and /cabal.config
. This includes:
stackage init # client defaults this to lts
stackage init lts # server currently defaults this to 2.0
stackage init nightly # server currently defaults this to 2015-04-02
stackage init lts/1 # server currently defaults this to 1.15
stackage init lts/1.14
stackage init nightly/2015-04-01
stackage init snapshot/any-named-snapshot
Should be ready to close.
Confirmed.
In future let's consider listing these things, as the regular user won't know what are the valid strings to put here.
@chrisdone Did your suggestion ever make it in? I was just struggling with that today: "What are valid snapshots?" Would be awesome to list them out somehow.
The
executable
target should bestackage-init
. This is one of the built-in plugins that come with the project and serves as a good demonstration.Setup a
cabal.config
file in the current directory by either receiving a snapshot hash or alias as argument, or by prompting the user to enter one. It may default tolts
with a "RET to choose default". Or optionally be likeEnter snapshot (tls/nightly/<hash>):
, so that one can just grab whatever lts or nightly is current. Maybe also support --lts or --nightly flag. There's a bit of freedom here, but think: convenient. Think of users first coming to hackage and also experts.