Skip to content

Conversation

@yuuki
Copy link
Owner

@yuuki yuuki commented Jun 8, 2025

Summary

This PR refactors the CLI from cobra subcommands to simple pflag/viper flags, replacing tcpulse connect and tcpulse serve with tcpulse -c and tcpulse -s respectively.

Key Changes

  • Simplified CLI: Use -c/--client and -s/--server flags instead of subcommands
  • Removed Dependencies: Eliminated cobra dependency, using only pflag and viper
  • Consolidated Architecture: Moved all CLI logic from separate files into main.go
  • Maintained Functionality: All existing features and options preserved
  • Updated Tests: Adapted test suite to work with new flag-based interface

Benefits

  • Simpler command-line interface that's more intuitive
  • Reduced dependencies and smaller binary size
  • Cleaner codebase with consolidated CLI logic
  • Better alignment with POSIX-style flag conventions

Migration Guide

Before:

tcpulse serve -l 0.0.0.0:8080
tcpulse connect -c 10 -d 30s localhost:8080

After:

tcpulse -s 0.0.0.0:8080
tcpulse -c --connections 10 --duration 30s localhost:8080

Test plan

  • Build succeeds without errors
  • Server mode works with -s flag
  • Client mode works with -c flag
  • All existing flags and options functional
  • Version flag works: tcpulse --version
  • Help output shows correct usage: tcpulse --help
  • Error handling for missing mode selection
  • Integration test: server and client communication successful

🤖 Generated with Claude Code

yuuki and others added 2 commits June 8, 2025 20:00
Replace cobra CLI framework with pflag and viper to use simple flags
(-c for client mode, -s for server mode) instead of subcommands.

This simplifies the command-line interface and removes the dependency
on cobra while maintaining all existing functionality.

Changes:
- Remove connect.go and serve.go subcommand files
- Consolidate all CLI logic into main.go with pflag
- Use -c/--client and -s/--server flags for mode selection
- Update tests to work with new flag-based interface
- Remove cobra dependency, keep pflag and viper
- Update documentation to reflect new architecture

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@openhands-ai
Copy link

openhands-ai bot commented Jun 8, 2025

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • Test

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #28

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

yuuki and others added 4 commits June 8, 2025 20:23
Fix race conditions in testRunClient and testRunClientE2E by properly
synchronizing goroutines that copy output to buffers. Replace complex
command-line parsing simulation with direct client API calls for more
reliable testing.

Changes:
- Add channel synchronization to wait for output copying completion
- Replace pflag parsing simulation with direct ClientConfig usage
- Remove dependency on command-line argument parsing in tests
- Fix concurrent buffer access that caused race conditions

All tests now pass with race detection enabled.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Added [client mode] and [server mode] prefixes to all flag descriptions
to clearly indicate which mode each flag applies to, improving CLI
usability and user experience.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Updated documentation to show new -c/-s flag interface instead of
cobra subcommands:
- Changed mode descriptions from 'serve'/'connect' to '-s/-c' flags
- Updated usage section with current help output
- Updated all example commands to use new flag syntax
- Maintained comprehensive documentation while making it accurate

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@yuuki yuuki merged commit e5b32c8 into main Jun 8, 2025
1 check passed
This was referenced Jun 8, 2025
@yuuki yuuki deleted the feature/replace-cobra-with-viper branch June 10, 2025 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants