jetmore / jetmore/swaks

swaks should have a non-interactive mode that prevents any prompts

Open
#110 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Perl
Stars
1.3k
Forks
95
PR merge metrics
No merged PRs in 30d

Description

`swaks` will automatically prompt for some information when it is missing from the command line, e.g.:

```
server ~ # swaks
To:
```

This is fine for interactive usage, but counterproductive when `swaks` is used in non-interactive situations, e.g. when called from a [Bats](https://github.com/bats-core/bats-core) test suite. I'm currently writing such a test suite, and whenever I accidentally call `swaks` with invalid arguments (in this case an empty `--to` argument because the subshell expression that was supposed to generate the address failed), it causes the whole test suite to hang, without any clear indication what's actually wrong:

```
server ~/smtp-tests (master) # ./some-test.bats -f 'some'
some-test.bats
some test description 1/1
[bats hangs here because swaks is waiting for input...]
```

[As Bats suppresses STDOUT on normal runs](https://bats-core.readthedocs.io/en/stable/writing-tests.html#printing-to-the-terminal), the `swaks` prompt text isn't actually visible by default, which makes this confusing to debug.

It would therefore be useful if `swaks` would be able to detect the non-interactive usage (e.g. with [`IO::Interactive`](https://metacpan.org/pod/IO::Interactive)), and/or support an option like `--non-interactive`. When in non-interactive mode, it should exit with an error message on STDERR and an exit code > 0 when any necessary information is missing.

Contributor guide

No contributing guide indexed for this repository

Research direction

No source files or project tests are named. Start by tracing swaks's command-line option parsing and prompt handling, then reproduce the empty --to case from a Bats test. Done means non-interactive use never prompts, reports missing information on STDERR, and exits nonzero.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.