diff --git a/cli/api.go b/cli/api.go index 0d1ac5c..8f5e980 100644 --- a/cli/api.go +++ b/cli/api.go @@ -8,7 +8,6 @@ import ( "github.com/AlexsanderHamir/prof/engine/benchmark" "github.com/AlexsanderHamir/prof/engine/collector" "github.com/AlexsanderHamir/prof/engine/tracker" - "github.com/AlexsanderHamir/prof/engine/version" "github.com/AlexsanderHamir/prof/internal/args" "github.com/AlexsanderHamir/prof/internal/config" "github.com/AlexsanderHamir/prof/internal/shared" @@ -42,7 +41,6 @@ func CreateRootCmd() *cobra.Command { rootCmd.AddCommand(createProfAuto()) rootCmd.AddCommand(createSetupCmd()) rootCmd.AddCommand(createTrackCmd()) - rootCmd.AddCommand(createVersionCmd()) return rootCmd } @@ -162,17 +160,6 @@ func createTrackManualCmd() *cobra.Command { return cmd } -func createVersionCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "version", - Short: "Shows the current version of prof and checks for updates.", - RunE: runVersion, - DisableFlagsInUseLine: true, - } - - return cmd -} - // createSetupCmd creates the setup subcommand func createSetupCmd() *cobra.Command { cmd := &cobra.Command{ @@ -224,14 +211,6 @@ func runBenchmarks(_ *cobra.Command, _ []string) error { return nil } -// runVersion handles the version command execution -func runVersion(_ *cobra.Command, _ []string) error { - current, latest := version.Check() - output := version.FormatOutput(current, latest) - fmt.Print(output) - return nil -} - // runSetup handles the setup command execution func runSetup(_ *cobra.Command, _ []string) error { return config.CreateTemplate() diff --git a/engine/version/version.go b/engine/version/version.go deleted file mode 100644 index 1e09df3..0000000 --- a/engine/version/version.go +++ /dev/null @@ -1,96 +0,0 @@ -package version - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "strings" - "time" -) - -// CurrentVersion is the current version of the prof tool. -const ( - currentVersion = "1.5.0" - gitHubAPIURL = "https://api.github.com/repos/AlexsanderHamir/prof/releases/latest" - waitTime = 10 -) - -// GitHubRelease represents the structure of a GitHub release response. -type GitHubRelease struct { - TagName string `json:"tag_name"` -} - -// normalizeVersion removes the 'v' prefix from a version string. -func normalizeVersion(version string) string { - return strings.TrimPrefix(version, "v") -} - -// getLatestVersion fetches the latest release tag from GitHub. -func getLatestVersion(ctx context.Context) (tagName string, err error) { - client := &http.Client{ - Timeout: waitTime * time.Second, - } - - req, err := http.NewRequestWithContext(ctx, http.MethodGet, gitHubAPIURL, nil) - if err != nil { - return "", fmt.Errorf("failed to create request: %w", err) - } - - resp, err := client.Do(req) - if err != nil { - return "", fmt.Errorf("failed to fetch latest version: %w", err) - } - - defer func() { - if closeErr := resp.Body.Close(); closeErr != nil { - if err == nil { - err = fmt.Errorf("response body close failed: %w", closeErr) - } - } - }() - - if resp.StatusCode != http.StatusOK { - return "", fmt.Errorf("GitHub API returned status %d", resp.StatusCode) - } - - var release GitHubRelease - if err = json.NewDecoder(resp.Body).Decode(&release); err != nil { - return "", fmt.Errorf("failed to decode GitHub release: %w", err) - } - - return release.TagName, nil -} - -// Check returns the current and latest available version. -func Check() (string, string) { - ctx, cancel := context.WithTimeout(context.Background(), waitTime*time.Second) - defer cancel() - - latest, err := getLatestVersion(ctx) - if err != nil { - return currentVersion, "" - } - return currentVersion, latest -} - -// FormatOutput formats the version information for display. -func FormatOutput(current, latest string) string { - output := fmt.Sprintf("Current version: %s\n", current) - - if latest == "" { - output += "Latest version: Unable to fetch (check your internet connection)\n" - return output - } - - normalizedCurrent := normalizeVersion(current) - normalizedLatest := normalizeVersion(latest) - - if normalizedLatest == normalizedCurrent { - output += fmt.Sprintf("Latest version: %s (up to date)\n", latest) - } else { - output += fmt.Sprintf("Latest version: %s (update available)\n", latest) - } - - return output -} diff --git a/prof_web_doc/docs/index.md b/prof_web_doc/docs/index.md index ea2d20d..a435bc5 100644 --- a/prof_web_doc/docs/index.md +++ b/prof_web_doc/docs/index.md @@ -143,9 +143,14 @@ prof track manual --base path/to/base/report/cpu.txt \ --output-format "detailed" ``` -## Result Examples +## Output Formats -Prof's performance comparison provides two output formats to help you understand performance changes at different levels of detail. +Prof's performance comparison provides multiple output formats to help you understand performance changes at different levels of detail and presentation. +**Currently supported formats:** + +- **Terminal (default)** +- **HTML** +- **JSON** ### Summary Format @@ -208,3 +213,15 @@ Change: +233.33% Severity: CRITICAL Recommendation: Critical regression! Immediate investigation required. ``` + +### HTML & JSON Output + +In addition to terminal display, Prof can export both **summary** and **detailed** reports in: + +- 📄 **HTML**: shareable and human-friendly +- 🧩 **JSON**: structured format for programmatic use or further integration + +```sh +--output-format summary-html +--output-format detailed-json +```