ja7ad / ja7ad/otp

Add Cobra CLI and Interactive Shell for otp-api

Open
#7 2 comments 0 reactions 1 assignee Claimed by @Likhil45 View on GitHub
enhancement good first issue
Dominant language
Go
Stars
43
Forks
1
PR merge metrics
No merged PRs in 30d

Description

We should introduce a **Cobra-powered CLI** for the `otp-api` application to allow users to interact with the OTP library and server via command-line and an optional interactive shell (REPL-like mode).

This will make the tool more flexible, allowing users to:

- 🛠️ Generate or validate TOTP/HOTP/OCRA directly from terminal
- ⚙️ Configure parameters (algorithm, digits, period, etc.)
- 🚀 Start or stop the HTTP API server
- 🧪 Run quick test commands interactively (REPL)

---

### 📌 **Proposed CLI Structure:**

```bash
otp-cli generate totp # Generate TOTP
otp-cli generate hotp # Generate HOTP
otp-cli generate ocra # Generate OCRA
otp-cli validate totp # Validate TOTP
otp-cli validate hotp # Validate HOTP
otp-cli validate ocra # Validate OCRA
otp-cli server start # Start the HTTP API server
otp-cli shell # Start interactive shell (REPL)
```

---

### ✅ **Why?**

- Improve developer ergonomics
- Useful for quick debugging, testing, and scripting
- CLI is a great companion to the API server
- Interactive mode can serve as a teaching tool or live demo utility

---

### 🧩 **Tasks:**

- [ ] Setup `spf13/cobra`
- [ ] Add `generate` and `validate` subcommands
- [ ] Add `server start` command to run API
- [ ] Add interactive shell with basic command auto-complete
- [ ] Add CLI flags for custom configuration

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.