<commit_before>{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE QuasiQuotes   #-}

-- | Command line options of cardano-auxx

module AuxxOptions
       ( AuxxOptions (..)
       , AuxxAction (..)
       , AuxxStartMode (..)
       , getAuxxOptions
       ) where

import           Universum

import           Data.Version (showVersion)
import qualified NeatInterpolation as N
import           Options.Applicative (CommandFields, Mod, Parser, command,
                     execParser, footerDoc, fullDesc, header, help, helper,
                     info, infoOption, long, maybeReader, metavar, option,
                     progDesc, strOption, subparser, value)
import           Pos.Communication (NodeId)
import           Text.PrettyPrint.ANSI.Leijen (Doc)

import           Paths_cardano_sl (version)
import qualified Pos.Client.CLI as CLI
import           Pos.Util.CompileInfo (CompileTimeInfo (..), HasCompileInfo,
                     compileInfo)

----------------------------------------------------------------------------
-- Types
----------------------------------------------------------------------------

data AuxxOptions = AuxxOptions
    { aoAction         :: !AuxxAction
    , aoCommonNodeArgs :: !CLI.CommonNodeArgs  -- ^ Common CLI args for nodes
    , aoPeers          :: ![NodeId]
    -- ^ Peers with which we want to communicate
    --   TODO: we also have topology, so it can be redundant.
    , aoStartMode      :: !AuxxStartMode
    }

data AuxxStartMode
    = Automatic
    | Light
    | WithConfiguration
    | WithNode
    deriving Eq

data AuxxAction
    = Repl
    | Cmd { cmd :: !Text }

----------------------------------------------------------------------------
-- Parse action
----------------------------------------------------------------------------

actionParser :: Parser AuxxAction
actionParser = subparser $ replParser <> cmdParser

replParser :: Mod CommandFields AuxxAction
replParser = command "repl" $ info (pure Repl) $
             progDesc "Run REPL in console to evaluate the commands."

cmdParser :: Mod CommandFields AuxxAction
cmdParser = command "cmd" $ info opts desc
  where opts = Cmd <$> strOption (long "commands"
                               <> metavar "CMD"
                               <> help "Commands to execute, comma-separated.")
        desc = progDesc "Execute a list of predefined commands."

----------------------------------------------------------------------------
-- Parse everything<commit_msg>[CDEC-398] Remove partial field accessors from `AuxxAction`<commit_after>{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE QuasiQuotes   #-}

-- | Command line options of cardano-auxx

module AuxxOptions
       ( AuxxOptions (..)
       , AuxxAction (..)
       , AuxxStartMode (..)
       , getAuxxOptions
       ) where

import           Universum

import           Data.Version (showVersion)
import qualified NeatInterpolation as N
import           Options.Applicative (CommandFields, Mod, Parser, command,
                     execParser, footerDoc, fullDesc, header, help, helper,
                     info, infoOption, long, maybeReader, metavar, option,
                     progDesc, strOption, subparser, value)
import           Pos.Communication (NodeId)
import           Text.PrettyPrint.ANSI.Leijen (Doc)

import           Paths_cardano_sl (version)
import qualified Pos.Client.CLI as CLI
import           Pos.Util.CompileInfo (CompileTimeInfo (..), HasCompileInfo,
                     compileInfo)

----------------------------------------------------------------------------
-- Types
----------------------------------------------------------------------------

data AuxxOptions = AuxxOptions
    { aoAction         :: !AuxxAction
    , aoCommonNodeArgs :: !CLI.CommonNodeArgs  -- ^ Common CLI args for nodes
    , aoPeers          :: ![NodeId]
    -- ^ Peers with which we want to communicate
    --   TODO: we also have topology, so it can be redundant.
    , aoStartMode      :: !AuxxStartMode
    }

data AuxxStartMode
    = Automatic
    | Light
    | WithConfiguration
    | WithNode
    deriving Eq

data AuxxAction
    = Repl
    | Cmd !Text

----------------------------------------------------------------------------
-- Parse action
----------------------------------------------------------------------------

actionParser :: Parser AuxxAction
actionParser = subparser $ replParser <> cmdParser

replParser :: Mod CommandFields AuxxAction
replParser = command "repl" $ info (pure Repl) $
             progDesc "Run REPL in console to evaluate the commands."

cmdParser :: Mod CommandFields AuxxAction
cmdParser = command "cmd" $ info opts desc
  where opts = Cmd <$> strOption (long "commands"
                               <> metavar "CMD"
                               <> help "Commands to execute, comma-separated.")
        desc = progDesc "Execute a list of predefined commands."

----------------------------------------------------------------------------
-- Parse everything
{'fraction_non_alphanumeric': 0.2249246231155779, 'fraction_numerical': 0.0006030150753768845, 'mean_word_length': 1.4061895551257253, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '478243', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1216, 'n_words': 358}