1
1
mirror of https://github.com/nmattia/niv.git synced 2024-11-07 11:28:45 +03:00

Add basic CLI for git dependencies

This commit is contained in:
Nicolas Mattia 2019-11-22 16:20:43 +01:00
parent 2663cc56e0
commit c3ec48dbb0

View File

@ -208,9 +208,10 @@ cmdInit = do
parseCmdAdd :: Opts.ParserInfo (IO ()) parseCmdAdd :: Opts.ParserInfo (IO ())
parseCmdAdd = parseCmdAdd =
Opts.info Opts.info
((uncurry (cmdAdd githubUpdate') <$> parseArgs) <**> Opts.helper) $ ((sp <|> (uncurry (cmdAdd githubUpdate') <$> parseArgs)) <**> Opts.helper) $
mconcat desc mconcat desc
where where
sp = Opts.subparser (Opts.hidden <> Opts.commandGroup "Experimental commands:" <> Opts.command "git" parseCmdAddGit)
parseArgs :: Opts.Parser (PackageName, Attrs) parseArgs :: Opts.Parser (PackageName, Attrs)
parseArgs = collapse <$> parseNameAndGHShortcut <*> parsePackageSpec parseArgs = collapse <$> parseNameAndGHShortcut <*> parsePackageSpec
parseNameAndGHShortcut = (,) <$> optName <*> parseGitHubShortcut parseNameAndGHShortcut = (,) <$> optName <*> parseGitHubShortcut
@ -249,6 +250,15 @@ parseCmdAdd =
" niv add my-package -v alpha-0.1 -t http://example.com/archive/<version>.zip" " niv add my-package -v alpha-0.1 -t http://example.com/archive/<version>.zip"
] ]
parseCmdAddGit :: Opts.ParserInfo (IO ())
parseCmdAddGit =
Opts.info
(putStrLn <$> parseArgs <**> Opts.helper) $
mconcat desc
where
parseArgs = Opts.strOption (Opts.long "message")
desc = [ Opts.progDesc "This echoes \"message\" back." ]
cmdAdd :: Update () a -> PackageName -> Attrs -> IO () cmdAdd :: Update () a -> PackageName -> Attrs -> IO ()
cmdAdd updateFunc packageName attrs = do cmdAdd updateFunc packageName attrs = do
job ("Adding package " <> T.unpack (unPackageName packageName)) $ do job ("Adding package " <> T.unpack (unPackageName packageName)) $ do