Skip to content

Commit

Permalink
fix: rename --parallel option to --threads for clarity
Browse files Browse the repository at this point in the history
Closes #80.
  • Loading branch information
vst committed Apr 17, 2024
1 parent 44f541c commit 6373e25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/HostPatrol/Cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions website/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ hosts:
This command connects to hosts in parallel and ignores all failed hosts by reporting errors in the output.
</p>

<p>If you want to change the number of concurrent tasks, do so with `--parallel` option:</p>
<p>
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:
</p>

<Code>
<pre>{`hostpatrol compile --parallel 10 --host my-host-1 --host my-host-2 ... > /tmp/hostpatrol-report.json`}</pre>
<pre>{`hostpatrol compile --threads 10 --host my-host-1 --host my-host-2 ... > /tmp/hostpatrol-report.json`}</pre>
</Code>

<p>
Expand Down

0 comments on commit 6373e25

Please sign in to comment.