feat(cli): add config view command with JSON output support#192
feat(cli): add config view command with JSON output support#192
Conversation
Add a new `config view` subcommand to display the current configuration. Supports both table (default) and JSON output formats via --format/-f flag. Table format masks sensitive token fields for security. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @AnnatarHe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the CLI by adding a new Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 20 files with indirect coverage changes 🚀 New features to boost your workflow:
|
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a new shelltime config view command, which is a great addition for inspecting the current configuration. The implementation supports both table and JSON output, with token masking in the table view for security. The code is well-structured. I've found a couple of areas for improvement: one related to platform-independent path construction, and a minor simplification in the logic for identifying sensitive fields. Overall, this is a solid feature addition.
| ctx, span := commandTracer.Start(c.Context, "config.view", trace.WithSpanKind(trace.SpanKindClient)) | ||
| defer span.End() | ||
|
|
||
| SetupLogger(os.ExpandEnv("$HOME/" + model.COMMAND_BASE_STORAGE_FOLDER)) |
There was a problem hiding this comment.
Hardcoding the path separator / and using os.ExpandEnv("$HOME") is not platform-independent. According to the repository's general rules, you should use os.UserHomeDir() to get the user's home directory and filepath.Join to construct paths. This will ensure your code works correctly across different operating systems like Windows.
Here's a suggested implementation:
homeDir, err := os.UserHomeDir()
if err != nil {
return fmt.Errorf("could not determine home directory: %w", err)
}
logPath := filepath.Join(homeDir, model.COMMAND_BASE_STORAGE_FOLDER)
SetupLogger(logPath)You'll need to import the path/filepath package.
References
- For platform-independent paths, use
filepath.Jointo combine segments andos.UserHomeDir()to get the home directory, rather than hardcoding path separators or environment variables like$HOME.
| value := field.String() | ||
| if value == "" { | ||
| value = "<empty>" | ||
| } else if strings.Contains(fullKey, "token") || strings.Contains(strings.ToLower(fullKey), "token") { |
There was a problem hiding this comment.
The first condition strings.Contains(fullKey, "token") is redundant. The second condition strings.Contains(strings.ToLower(fullKey), "token") already performs a case-insensitive check for "token", which covers the first case as well. You can simplify this line by removing the redundant check.
| } else if strings.Contains(fullKey, "token") || strings.Contains(strings.ToLower(fullKey), "token") { | |
| } else if strings.Contains(strings.ToLower(fullKey), "token") { |
Swap GetCachedCost() and NotifyActivity() call order to ensure activeRanges is populated before the timer goroutine runs fetchActiveRanges(). Also add debug log for cc_info socket events. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Release-As: 0.1.53
Summary
shelltime config viewcommand to display current configuration--format/-fflagTest plan
go build ./...shelltime config view(table output with masked tokens)shelltime config view -f json(JSON output)--helpdisplays correctly🤖 Generated with Claude Code