From 6373e2580efb9a3c865f57ba70035f39eb8624d1 Mon Sep 17 00:00:00 2001
From: Vehbi Sinan Tunalioglu
Date: Wed, 17 Apr 2024 08:29:37 +0800
Subject: [PATCH] fix: rename --parallel option to --threads for clarity
Closes #80.
---
README.md | 7 ++++---
src/HostPatrol/Cli.hs | 6 +++---
website/src/app/page.tsx | 7 +++++--
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index 9a15257..a920a69 100644
--- a/README.md
+++ b/README.md
@@ -76,12 +76,13 @@ hostpatrol compile --host my-host-1 --host my-host-2 > /tmp/hostpatrol-report.js
This command connects to hosts in parallel and ignores all failed
hosts by reporting errors in the output.
-> If you want to change the number of concurrent tasks, do so with
-> `--parallel` option:
+> If you want to change the number of maximum number of threads to use
+> for concurrent patrol tasks, do so with `--threads` option that
+> defaults to `4` otherwise:
>
>
> ```sh
-> hostpatrol compile --parallel 10 --host my-host-1 --host my-host-2 ... > /tmp/hostpatrol-report.json
+> hostpatrol compile --threads 10 --host my-host-1 --host my-host-2 ... > /tmp/hostpatrol-report.json
> ```
Alternatively, you can use a configuration file which has additional
diff --git a/src/HostPatrol/Cli.hs b/src/HostPatrol/Cli.hs
index 911c689..edfc113 100644
--- a/src/HostPatrol/Cli.hs
+++ b/src/HostPatrol/Cli.hs
@@ -64,18 +64,18 @@ commandCompile = OA.hsubparser (OA.command "compile" (OA.info parser infomod) <>
doCompile
<$> OA.optional (OA.strOption (OA.short 'c' <> OA.long "config" <> OA.action "file" <> OA.help "Path to the configuration file."))
<*> OA.many (OA.strOption (OA.short 'h' <> OA.long "host" <> OA.help "Remote host (in SSH destination format)."))
- <*> OA.option OA.auto (OA.short 'p' <> OA.long "parallel" <> OA.value 4 <> OA.showDefault <> OA.help "Number of hosts to hit concurrently.")
+ <*> OA.option OA.auto (OA.short 't' <> OA.long "threads" <> OA.value 4 <> OA.showDefault <> OA.help "Maximum number of threads to use for concurrent patrols.")
-- | @compile@ CLI command program.
doCompile :: Maybe FilePath -> [T.Text] -> Int -> IO ExitCode
-doCompile cpath dests par = do
+doCompile cpath dests threads = do
baseConfig <- maybe (pure (Config.Config [] [])) Config.readConfigFile cpath
let config =
baseConfig
{ Config._configHosts = Config._configHosts baseConfig <> fmap _mkHost dests
}
- res <- runExceptT (compileReport par config)
+ res <- runExceptT (compileReport threads config)
case res of
Left err -> BLC.hPutStrLn stderr (Aeson.encode err) >> pure (ExitFailure 1)
Right sr -> BLC.putStrLn (Aeson.encode sr) >> pure ExitSuccess
diff --git a/website/src/app/page.tsx b/website/src/app/page.tsx
index 38380bb..0888fcb 100644
--- a/website/src/app/page.tsx
+++ b/website/src/app/page.tsx
@@ -90,10 +90,13 @@ hosts:
This command connects to hosts in parallel and ignores all failed hosts by reporting errors in the output.
- If you want to change the number of concurrent tasks, do so with `--parallel` option:
+
+ If you want to change the number of maximum number of threads to use for concurrent patrol tasks, do so
+ with `--threads` option that defaults to `4` otherwise:
+
- {`hostpatrol compile --parallel 10 --host my-host-1 --host my-host-2 ... > /tmp/hostpatrol-report.json`}
+ {`hostpatrol compile --threads 10 --host my-host-1 --host my-host-2 ... > /tmp/hostpatrol-report.json`}