Repository navigation
chore: Split CLI UI and tool docs helpers #1487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package clicore | ||
|
|
||
| import "github.com/hatayama/unity-cli-loop/common/tooldocs" | ||
|
|
||
| const ( | ||
| DynamicCodeFileFlagName = tooldocs.DynamicCodeFileFlagName | ||
| DynamicCodeFileOptionName = tooldocs.DynamicCodeFileOptionName | ||
| DynamicCodeFileOptionUsage = tooldocs.DynamicCodeFileOptionUsage | ||
| DynamicCodeFileOptionDescription = tooldocs.DynamicCodeFileOptionDescription | ||
|
|
||
| ProjectPathFlagName = tooldocs.ProjectPathFlagName | ||
| ReloadExternalSceneChangesPropertyName = tooldocs.ReloadExternalSceneChangesPropertyName | ||
| ) | ||
|
|
||
| type OptionHelpEntry = tooldocs.OptionHelpEntry | ||
|
|
||
| func VisibleOptionHelpEntriesForTool(tool ToolDefinition) []OptionHelpEntry { | ||
| return tooldocs.VisibleOptionHelpEntriesForTool(tool) | ||
| } | ||
|
|
||
| func FindProperty(tool ToolDefinition, kebabName string) (string, ToolProperty, bool, bool) { | ||
| return tooldocs.FindProperty(tool, kebabName) | ||
| } | ||
|
|
||
| func OptionNameForProperty(toolName string, propertyName string, property ToolProperty) string { | ||
| return tooldocs.OptionNameForProperty(toolName, propertyName, property) | ||
| } | ||
|
|
||
| func VisibleOptionNamesForTool(tool ToolDefinition) []string { | ||
| return tooldocs.VisibleOptionNamesForTool(tool) | ||
| } | ||
|
|
||
| func IsBooleanProperty(property ToolProperty) bool { | ||
| return tooldocs.IsBooleanProperty(property) | ||
| } | ||
|
|
||
| func IsNegatedBooleanProperty(property ToolProperty) bool { | ||
| return tooldocs.IsNegatedBooleanProperty(property) | ||
| } | ||
|
|
||
| func OptionSummary(toolName string, propertyName string, property ToolProperty) string { | ||
| return tooldocs.OptionSummary(toolName, propertyName, property) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package clicore | ||
|
|
||
| import ( | ||
| "io" | ||
|
|
||
| "github.com/hatayama/unity-cli-loop/common/ui" | ||
| "github.com/hatayama/unity-cli-loop/common/unityipc" | ||
| ) | ||
|
|
||
| type TerminalSpinner = ui.TerminalSpinner | ||
|
|
||
| func NewToolSpinner(stderr io.Writer, command string) *TerminalSpinner { | ||
| return ui.NewToolSpinner(stderr, shouldShowToolFeedback(command)) | ||
| } | ||
|
|
||
| func NewLaunchSpinner(stdout io.Writer, stderr io.Writer) *TerminalSpinner { | ||
| return ui.NewLaunchSpinner(stdout, stderr) | ||
| } | ||
|
|
||
| func NewSpinnerProgressFunc(spinner *TerminalSpinner, executingMessage string) unityipc.ProgressFunc { | ||
| return ui.NewSpinnerProgressFunc(spinner, executingMessage) | ||
| } | ||
|
|
||
| func shouldShowToolFeedback(command string) bool { | ||
| return command != ExecuteDynamicCodeCommandName | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package clicore | ||
|
|
||
| import "github.com/hatayama/unity-cli-loop/common/vibelog" | ||
|
|
||
| const ( | ||
| CLIVibeLogDirectory = vibelog.CLIVibeLogDirectory | ||
| CLIVibeLogPrefix = vibelog.CLIVibeLogPrefix | ||
| CLIVibeLogEnvName = vibelog.CLIVibeLogEnvName | ||
| ) | ||
|
|
||
| type CLIVibeLogEntry = vibelog.CLIVibeLogEntry | ||
|
|
||
| func NewCLIVibeCorrelationID() string { | ||
| return vibelog.NewCLIVibeCorrelationID() | ||
| } | ||
|
|
||
| func WriteCLIVibeLog(projectRoot string, entry CLIVibeLogEntry) error { | ||
| return vibelog.WriteCLIVibeLog(projectRoot, entry) | ||
| } | ||
|
|
||
| func IsCLIVibeLogEnabled() bool { | ||
| return vibelog.IsCLIVibeLogEnabled() | ||
| } | ||
|
|
||
| func ProjectIdentity(projectRoot string) string { | ||
| return vibelog.ProjectIdentity(projectRoot) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package clicore | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "testing" | ||
| ) | ||
|
|
||
| func enableCliVibeLog(t *testing.T) { | ||
| t.Helper() | ||
| t.Setenv(CLIVibeLogEnvName, "1") | ||
| } | ||
|
|
||
| func readOnlyCliVibeLog(t *testing.T, projectRoot string) string { | ||
| t.Helper() | ||
| logFiles, err := filepath.Glob(filepath.Join(projectRoot, CLIVibeLogDirectory, CLIVibeLogPrefix+"_*.json")) | ||
| if err != nil { | ||
| t.Fatalf("failed to glob CLI Vibe logs: %v", err) | ||
| } | ||
| if len(logFiles) != 1 { | ||
| t.Fatalf("expected one CLI Vibe log, got %d: %#v", len(logFiles), logFiles) | ||
| } | ||
| content, err := os.ReadFile(logFiles[0]) | ||
| if err != nil { | ||
| t.Fatalf("failed to read CLI Vibe log: %v", err) | ||
| } | ||
| return string(content) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package tooldocs | ||
|
|
||
| import "strings" | ||
|
|
||
| func FirstHelpLine(description string) string { | ||
| for _, line := range strings.Split(description, "\n") { | ||
| trimmed := strings.TrimSpace(line) | ||
| if trimmed != "" { | ||
| return trimmed | ||
| } | ||
| } | ||
| return "" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.