Interactive Mode

How mkunit prompts for missing options.

How It Works

mkunit is designed to be both interactive and scriptable. When you run a command without all required options, mkunit will prompt you for the missing information. If you provide all required options, it runs without any prompts.

Example: Interactive Service Creation

$ mkunit service myapp

Service name: myapp
Command to run: ./server
Working directory [/home/user/myapp]:
Restart policy [on-failure]: always
User service or system? [user]:

Created myapp.service

Install now? [Y/n]: y
Installed to ~/.config/systemd/user/myapp.service

Start now? [Y/n]: y
Started myapp.service

Example: Non-Interactive Service Creation

The same service created without any prompts:

mkunit service myapp \
  --exec "./server" \
  --workdir /home/user/myapp \
  --restart always \
  --install --start

When Does mkunit Prompt?

mkunit prompts when:

mkunit does NOT prompt when:

Defaults and Suggestions

Interactive prompts show defaults in brackets. Press Enter to accept:

Working directory [/home/user/myapp]:    # Press Enter for /home/user/myapp
Restart policy [on-failure]:              # Press Enter for on-failure

mkunit infers smart defaults:

Disabling Interactive Mode

Use --no-interactive to disable prompts:

# Fails if --exec is missing
mkunit service myapp --no-interactive

# Works - all required options provided
mkunit service myapp --exec "./server" --no-interactive

This is useful for:

Environment Detection

mkunit automatically detects non-interactive environments:

# These disable interactive mode automatically:

# Piped input
echo "something" | mkunit service myapp

# Non-TTY stdin
mkunit service myapp < /dev/null

# CI environments (detected via CI env var)
CI=true mkunit service myapp

Combining Interactive and Flags

You can provide some options and let mkunit ask for the rest:

$ mkunit service myapp --exec "./server"
# Only prompts for optional fields not provided:

Working directory [/home/user/myapp]:
Restart policy [on-failure]:

Created myapp.service
Install now? [Y/n]:

Confirmation Prompts

Some commands ask for confirmation:

$ mkunit remove myapp
Remove myapp.service? This will:
  - Stop the service if running
  - Disable the service
  - Delete the unit file

Are you sure? [y/N]: y
Removed myapp.service

Skip with --force:

mkunit remove myapp --force

See Also