Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename --parallel option to --threads for clarity #81

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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