Skip to content

Add login token command to save API token to config file - #2

Merged
scottlovegrove merged 1 commit into
mainfrom
scottl/login-token-command
Jan 15, 2026
Merged

Add login token command to save API token to config file#2
scottlovegrove merged 1 commit into
mainfrom
scottl/login-token-command

Conversation

@scottlovegrove

Copy link
Copy Markdown
Collaborator

Summary

  • Adds tw login token <TOKEN> command that saves API tokens to ~/.config/twist-cli/config.json
  • Cross-platform support using existing config system with proper directory creation
  • Simple implementation with token validation (minimum 10 characters)
  • Comprehensive test coverage with 4 test cases including success, error handling, token trimming, and help

Changes

  • src/lib/auth.ts: Added saveApiToken() function using existing config system
  • src/commands/login.ts: New login command group with token subcommand
  • src/index.ts: Registered new login command in main entry point
  • src/tests/login.test.ts: Comprehensive test coverage for all functionality

Usage

# Save API token
tw login token your_api_token_here

# Show help
tw login --help
tw login token --help

Test plan

  • TypeScript compilation passes
  • All tests pass (84/84 total)
  • Manual testing verified:
    • Help system works correctly
    • Token saving creates proper config file at ~/.config/twist-cli/config.json
    • Config directory auto-creation works
    • Token validation works (rejects < 10 characters)
    • Existing config preservation works

🤖 Generated with Claude Code

- Adds `tw login token <TOKEN>` command that saves API tokens to ~/.config/twist-cli/config.json
- Cross-platform support using existing config system with proper directory creation
- Simple implementation with token validation (minimum 10 characters)
- Comprehensive test coverage with 4 test cases including success, error handling, token trimming, and help

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
@scottlovegrove scottlovegrove added the 👀 Show PR PR must be reviewed before or after merging label Jan 15, 2026
@scottlovegrove scottlovegrove self-assigned this Jan 15, 2026
@scottlovegrove
scottlovegrove merged commit 79fa0f5 into main Jan 15, 2026
@scottlovegrove
scottlovegrove requested a review from gnapse January 15, 2026 16:20
@gnapse
gnapse deleted the scottl/login-token-command branch January 15, 2026 16:42
@gnapse

gnapse commented Jan 15, 2026

Copy link
Copy Markdown
Collaborator

Updated the README to document the new tw login token command in the Setup section. Thanks!

@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released 👀 Show PR PR must be reviewed before or after merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants