Replace implicit note shorthand with explicit addnote command and split README
Two changes: 1. structured-add-commands: The implicit note shorthand (kb "text") caused accidental note creation from mistyped commands. Replaced with explicit kb addnote <text> command. Root command reverts to standard Cobra behaviour. Updated examples, tests, SKILL.md, and specs. 2. split-readme-developer-docs: Moved build-from-source instructions, release process, API reference, and ROCm migration notes from README.md into a new DEVELOPER.md. README now links to DEVELOPER.md for dev workflows. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+45
-30
@@ -6,36 +6,6 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRootCmd_SingleWordRejected(t *testing.T) {
|
||||
rootCmd.SetArgs([]string{"infow"})
|
||||
|
||||
var stderr bytes.Buffer
|
||||
rootCmd.SetErr(&stderr)
|
||||
|
||||
err := rootCmd.Execute()
|
||||
if err == nil {
|
||||
t.Fatal("expected error for single bare word, got nil")
|
||||
}
|
||||
|
||||
errMsg := err.Error()
|
||||
if !strings.Contains(errMsg, `unknown command "infow"`) {
|
||||
t.Errorf("expected error to mention unknown command, got: %s", errMsg)
|
||||
}
|
||||
if !strings.Contains(errMsg, "multiple words") {
|
||||
t.Errorf("expected error to suggest multiple words, got: %s", errMsg)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRootCmd_MultipleWordsNotRejected(t *testing.T) {
|
||||
rootCmd.SetArgs([]string{"remember", "to", "update", "dns"})
|
||||
|
||||
err := rootCmd.Execute()
|
||||
// Will fail at API call (no server), but should NOT be the "unknown command" error
|
||||
if err != nil && strings.Contains(err.Error(), "unknown command") {
|
||||
t.Errorf("multi-word input should not be rejected as unknown command, got: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestRootCmd_NoArgs_ShowsHelp(t *testing.T) {
|
||||
rootCmd.SetArgs([]string{})
|
||||
|
||||
@@ -52,3 +22,48 @@ func TestRootCmd_NoArgs_ShowsHelp(t *testing.T) {
|
||||
t.Errorf("expected help output, got: %s", output)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRootCmd_UnknownCommand_ReturnsError(t *testing.T) {
|
||||
rootCmd.SetArgs([]string{"notacommand"})
|
||||
|
||||
var stderr bytes.Buffer
|
||||
rootCmd.SetErr(&stderr)
|
||||
|
||||
err := rootCmd.Execute()
|
||||
if err == nil {
|
||||
t.Fatal("expected error for unknown command, got nil")
|
||||
}
|
||||
|
||||
errMsg := err.Error()
|
||||
if !strings.Contains(errMsg, "unknown command") {
|
||||
t.Errorf("expected 'unknown command' error, got: %s", errMsg)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddnoteCmd_NoArgs_ReturnsError(t *testing.T) {
|
||||
rootCmd.SetArgs([]string{"addnote"})
|
||||
|
||||
err := rootCmd.Execute()
|
||||
if err == nil {
|
||||
t.Fatal("expected error for addnote with no args, got nil")
|
||||
}
|
||||
|
||||
errMsg := err.Error()
|
||||
if !strings.Contains(errMsg, "requires a note text argument") {
|
||||
t.Errorf("expected 'requires a note text argument' error, got: %s", errMsg)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddnoteCmd_TooManyArgs_ReturnsError(t *testing.T) {
|
||||
rootCmd.SetArgs([]string{"addnote", "hello", "world"})
|
||||
|
||||
err := rootCmd.Execute()
|
||||
if err == nil {
|
||||
t.Fatal("expected error for addnote with too many args, got nil")
|
||||
}
|
||||
|
||||
errMsg := err.Error()
|
||||
if !strings.Contains(errMsg, "quote your note text") {
|
||||
t.Errorf("expected 'accepts 1 arg' error, got: %s", errMsg)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user