From 6fdbed5e617541a46d4610e5c5f034b4e274c04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 11 Mar 2025 19:24:28 +0100 Subject: Accept jobs to run on command-line Changelog: Accept names of jobs to run as command-line arguments --- src/Command.hs | 11 ++++++-- src/Command/Run.hs | 80 ++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 58 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/Command.hs b/src/Command.hs index 8ca0655..2c511df 100644 --- a/src/Command.hs +++ b/src/Command.hs @@ -6,6 +6,7 @@ module Command ( CommandArgumentsType(..), CommandExec(..), + tfail, CommandInput(..), getCommonOptions, getConfigPath, @@ -20,6 +21,7 @@ import Control.Monad.Reader import Data.Kind import Data.Text (Text) import Data.Text qualified as T +import Data.Text.IO qualified as T import System.Console.GetOpt import System.Exit @@ -84,9 +86,12 @@ newtype CommandExec a = CommandExec (ReaderT CommandInput IO a) deriving (Functor, Applicative, Monad, MonadIO) instance MonadFail CommandExec where - fail err = liftIO $ do - hPutStrLn stderr err - exitFailure + fail = tfail . T.pack + +tfail :: Text -> CommandExec a +tfail err = liftIO $ do + T.hPutStrLn stderr err + exitFailure data CommandInput = CommandInput { ciOptions :: CommonOptions diff --git a/src/Command/Run.hs b/src/Command/Run.hs index b6fd429..3968196 100644 --- a/src/Command/Run.hs +++ b/src/Command/Run.hs @@ -8,6 +8,7 @@ import Control.Exception import Control.Monad import Control.Monad.Reader +import Data.Either import Data.List import Data.Text (Text) import Data.Text qualified as T @@ -15,7 +16,6 @@ import Data.Text.IO qualified as T import System.Console.GetOpt import System.Directory -import System.Exit import System.FilePath import System.FilePath.Glob import System.IO @@ -45,8 +45,8 @@ instance Command RunCommand where commandUsage _ = T.pack $ unlines $ [ "Usage: minici run" , " run jobs for commits on current branch not yet in upstream branch" - , " or: minici run [--since-upstream=]" - , " run jobs for commits on not yet in its upstream ref" + , " or: minici run ..." + , " run jobs specified on the command line" , " or: minici run [--range=].." , " run jobs for commits in given range" , " or: minici run