[PR #2647] [CLOSED] cmd/headscale: migrate CLI from Cobra to command #2781

Closed
opened 2025-12-29 04:18:57 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/2647
Author: @kradalby
Created: 6/17/2025
Status: Closed

Base: mainHead: kradalby/cli-experiment2


📝 Commits (1)

  • 3f01944 cmd/headscale: migrate CLI from Cobra to command

📊 Changes

43 files changed (+4038 additions, -2603 deletions)

View changed files

📝 CHANGELOG.md (+34 -0)
cmd/headscale/apikey.go (+138 -0)
cmd/headscale/cli/api_key.go (+0 -222)
cmd/headscale/cli/configtest.go (+0 -22)
cmd/headscale/cli/debug.go (+0 -127)
cmd/headscale/cli/dump_config.go (+0 -28)
cmd/headscale/cli/generate.go (+0 -42)
cmd/headscale/cli/mockoidc.go (+0 -146)
cmd/headscale/cli/nodes.go (+0 -871)
cmd/headscale/cli/policy.go (+0 -121)
cmd/headscale/cli/preauthkeys.go (+0 -234)
cmd/headscale/cli/pterm_style.go (+0 -19)
cmd/headscale/cli/root.go (+0 -107)
cmd/headscale/cli/serve.go (+0 -32)
cmd/headscale/cli/users.go (+0 -325)
cmd/headscale/cli/utils.go (+0 -202)
cmd/headscale/cli/version.go (+0 -23)
cmd/headscale/commands_test.go (+442 -0)
cmd/headscale/common.go (+424 -0)
cmd/headscale/dev.go (+243 -0)

...and 23 more files

📄 Description

This is currently just some playing around, lets see how it turns out.

Migrate the CLI implementation from Cobra to creachadair/command and creachadair/flax for improved maintainability and performance.

  • Replace Cobra command structure with command framework
  • Implement struct-based flag binding using flax
  • Add enhanced table formatting and output handling
  • Update integration tests for new CLI syntax
  • Replace --identifier with --node flag in node commands
  • Update command structure for consistency
  • Add backward compatibility aliases

The new CLI maintains feature parity while providing better error handling, interactive confirmations, and consistent patterns.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/2647 **Author:** [@kradalby](https://github.com/kradalby) **Created:** 6/17/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `kradalby/cli-experiment2` --- ### 📝 Commits (1) - [`3f01944`](https://github.com/juanfont/headscale/commit/3f01944dc45b279f11d3ec8e5ed0c80dc6d72622) cmd/headscale: migrate CLI from Cobra to command ### 📊 Changes **43 files changed** (+4038 additions, -2603 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+34 -0) ➕ `cmd/headscale/apikey.go` (+138 -0) ➖ `cmd/headscale/cli/api_key.go` (+0 -222) ➖ `cmd/headscale/cli/configtest.go` (+0 -22) ➖ `cmd/headscale/cli/debug.go` (+0 -127) ➖ `cmd/headscale/cli/dump_config.go` (+0 -28) ➖ `cmd/headscale/cli/generate.go` (+0 -42) ➖ `cmd/headscale/cli/mockoidc.go` (+0 -146) ➖ `cmd/headscale/cli/nodes.go` (+0 -871) ➖ `cmd/headscale/cli/policy.go` (+0 -121) ➖ `cmd/headscale/cli/preauthkeys.go` (+0 -234) ➖ `cmd/headscale/cli/pterm_style.go` (+0 -19) ➖ `cmd/headscale/cli/root.go` (+0 -107) ➖ `cmd/headscale/cli/serve.go` (+0 -32) ➖ `cmd/headscale/cli/users.go` (+0 -325) ➖ `cmd/headscale/cli/utils.go` (+0 -202) ➖ `cmd/headscale/cli/version.go` (+0 -23) ➕ `cmd/headscale/commands_test.go` (+442 -0) ➕ `cmd/headscale/common.go` (+424 -0) ➕ `cmd/headscale/dev.go` (+243 -0) _...and 23 more files_ </details> ### 📄 Description This is currently just some playing around, lets see how it turns out. Migrate the CLI implementation from Cobra to creachadair/command and creachadair/flax for improved maintainability and performance. - Replace Cobra command structure with command framework - Implement struct-based flag binding using flax - Add enhanced table formatting and output handling - Update integration tests for new CLI syntax - Replace --identifier with --node flag in node commands - Update command structure for consistency - Add backward compatibility aliases The new CLI maintains feature parity while providing better error handling, interactive confirmations, and consistent patterns. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 04:18:57 +01:00
adam closed this issue 2025-12-29 04:18:57 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2781