mirror of
https://github.com/github/semantic.git
synced 2025-01-09 00:56:32 +03:00
Merge branch 'diff-with-no-index-args-parse' into diff-with-no-index
This commit is contained in:
commit
a269e6c28a
@ -1,24 +1,40 @@
|
|||||||
module Arguments (Arguments(..), args) where
|
module Arguments (Arguments(..), ExtraArg(..), args, filePathsFromArgs, maybeShasFromArgs) where
|
||||||
|
|
||||||
import Data.Functor.Both
|
import Data.Functor.Both
|
||||||
|
import Data.Monoid
|
||||||
import Prelude
|
import Prelude
|
||||||
import qualified Renderer as R
|
import qualified Renderer as R
|
||||||
|
|
||||||
-- | The command line arguments to the application.
|
data ExtraArg = ShaPair (Both (Maybe String)) | FileArg FilePath deriving (Show)
|
||||||
data Arguments = Arguments {
|
|
||||||
format :: R.Format,
|
|
||||||
maybeShas :: Both (Maybe String),
|
|
||||||
maybeTimeout :: Maybe Float,
|
|
||||||
output :: Maybe FilePath,
|
|
||||||
noIndex :: Bool,
|
|
||||||
filePaths :: [FilePath] }
|
|
||||||
deriving (Show)
|
|
||||||
|
|
||||||
args :: String -> String -> [FilePath] -> R.Format -> Arguments
|
-- | The command line arguments to the application.
|
||||||
args sha1 sha2 paths format = Arguments { format = format
|
data Arguments = Arguments
|
||||||
, maybeShas = Just <$> both sha1 sha2
|
{ format :: R.Format
|
||||||
, filePaths = paths
|
, maybeTimeout :: Maybe Float
|
||||||
, maybeTimeout = Just 10.0
|
, output :: Maybe FilePath
|
||||||
, output = Nothing
|
, noIndex :: Bool
|
||||||
, noIndex = False
|
, extraArgs :: [ExtraArg]
|
||||||
}
|
} deriving (Show)
|
||||||
|
|
||||||
|
args :: String -> String -> [String] -> R.Format -> Arguments
|
||||||
|
args sha1 sha2 filePaths format = Arguments
|
||||||
|
{ format = format
|
||||||
|
, maybeTimeout = Just 10.0
|
||||||
|
, output = Nothing
|
||||||
|
, noIndex = False
|
||||||
|
, extraArgs = [ShaPair (Just <$> both sha1 sha2)] <> (FileArg <$> filePaths)
|
||||||
|
}
|
||||||
|
|
||||||
|
filePathsFromArgs :: Arguments -> [FilePath]
|
||||||
|
filePathsFromArgs Arguments{..} = go extraArgs
|
||||||
|
where
|
||||||
|
go [] = []
|
||||||
|
go (FileArg x:xs) = x : go xs
|
||||||
|
go (_:xs) = go xs
|
||||||
|
|
||||||
|
maybeShasFromArgs :: Arguments -> Both (Maybe String)
|
||||||
|
maybeShasFromArgs Arguments{..} = go extraArgs
|
||||||
|
where
|
||||||
|
go [] = both Nothing Nothing
|
||||||
|
go (ShaPair x:_) = x
|
||||||
|
go (_:xs) = go xs
|
||||||
|
Loading…
Reference in New Issue
Block a user