Skip to content

Env Command#3

Merged
8bitAlex merged 10 commits into
mainfrom
env
Oct 2, 2025
Merged

Env Command#3
8bitAlex merged 10 commits into
mainfrom
env

Conversation

@8bitAlex
Copy link
Copy Markdown
Owner

@8bitAlex 8bitAlex commented Oct 2, 2025

This pull request introduces significant improvements and refactoring to the Raid CLI's environment and profile management, updates documentation, and adds new dependencies. The environment system is now more robust, supporting listing, activating, and executing environments with improved configuration and variable handling. The profile command is streamlined, and documentation is expanded to give a clearer overview of the project architecture and usage.

Environment Management Enhancements:

  • Refactored the environment system to provide functions for listing, setting, getting, and executing environments, including handling environment variables via .env files using the new godotenv dependency. (src/internal/lib/env.go, go.mod, [1] [2]
  • Added a new raid env list command to display all available environments. (src/cmd/env/list.go, src/cmd/env/list.goR1-R25)
  • Updated the raid env command to support querying and setting the active environment, with improved error handling and user feedback. (src/cmd/env/env.go, src/cmd/env/env.goR4-R44)

Profile Management Improvements:

  • Streamlined the raid profile command to both display and set the active profile, removing the redundant profile use subcommand. (src/cmd/profile/profile.go, src/cmd/profile/use.go, [1] [2] [3]
  • Updated profile logic to cache and retrieve environments, and improved the active profile getter to use the cached context if available. (src/internal/lib/profile.go, [1] [2]
  • Changed the profile listing command to use the new ListAll method. (src/cmd/profile/list.go, src/cmd/profile/list.goL14-R14)

Documentation and Usability:

  • Added a comprehensive project overview and architecture guide in .github/copilot-instructions.md.
  • Expanded the README.md with platform badges, clearer installation instructions, and improved best practices for handling sensitive information. [1] [2]

Configuration and Dependency Updates:

  • Introduced new configuration constants for file paths and flags, improving consistency across the codebase. (src/internal/lib/config.go, src/internal/lib/config.goR8-R16)
  • Added the godotenv package for environment variable file management. (go.mod, go.modR11)

These changes collectively make environment and profile management more intuitive, robust, and user-friendly, while also improving documentation and code maintainability.


Note

Adds environment listing/activation/execution with .env handling, replaces profile use with direct profile set/display, and refactors core compile→load APIs with related config and utilities updates.

  • CLI:
    • Environments: raid env now shows active env (no args), sets env, and executes it; new raid env list subcommand.
    • Profiles: raid profile now displays or sets the active profile; removes profile use subcommand; profile list uses new listing API.
  • Core/Lib:
    • Introduce env types/APIs (SetEnv, GetEnv, ListEnvs, ExecuteEnv) with .env file management via godotenv.
    • Add environments to Profile and Repo; cache profile/env in Context.
    • Rename compile cycle to load (CompileLoad, ForceCompileForceLoad).
    • Centralize config constants; move from strings.go to config.go and delete strings.go.
    • Update schema path constants and validation references.
    • Change sys.CreateFile to return (file, error); add utils.MergeErr and refactor cobra helpers.
  • Docs:
    • Add architecture/overview in .github/copilot-instructions.md and expand README.md with badges, install notes, and best practices.
  • Deps:
    • Add github.com/joho/godotenv for env file handling.

Written by Cursor Bugbot for commit d35f72b. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings October 2, 2025 02:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors the Raid CLI's core functionality by renaming compilation functions to "Load", introducing a new environment management system, consolidating profile commands, and improving code organization.

  • Function renaming: Updates Compile/ForceCompile to Load/ForceLoad throughout the codebase
  • Environment management: Adds comprehensive environment handling with .env file support via godotenv
  • Command consolidation: Merges profile use functionality into the main profile command

Reviewed Changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/raid/raid.go Renames compilation functions to Load/ForceLoad
src/raid/profile/profile.go Updates function names and comment formatting
src/raid/env/env.go Adds new environment management API layer
src/internal/utils/cobra-ext.go Extracts error merging to common utilities
src/internal/utils/Common.go Provides shared error merging functionality
src/internal/sys/system.go Improves file creation with error handling
src/internal/lib/strings.go Removes constants (moved to config.go)
src/internal/lib/repo.go Adds environment support to repository struct
src/internal/lib/profile.go Enhances profile caching and environment handling
src/internal/lib/lib.go Updates load functions and context management
src/internal/lib/env.go Implements comprehensive environment management
src/internal/lib/config.go Consolidates configuration constants
src/cmd/profile/use.go Removes standalone use command
src/cmd/profile/profile.go Consolidates profile display and setting
src/cmd/profile/list.go Updates to use new ListAll function
src/cmd/env/list.go Adds environment listing command
src/cmd/env/env.go Implements environment query and execution
go.mod Adds godotenv dependency
README.md Updates documentation with improved structure
.github/copilot-instructions.md Adds comprehensive project architecture guide

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/internal/lib/profile.go Outdated
Comment thread src/internal/lib/env.go
Comment thread src/internal/lib/env.go Outdated
8bitAlex and others added 2 commits October 1, 2025 19:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (b6614c1) to head (d35f72b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main      #3   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files          1       1           
  Lines          2       2           
=====================================
  Misses         2       2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Comment thread src/cmd/env/env.go
cmd.PrintErrln("Failed to switch environment:", err)
}
raid.ForceLoad()
if err := env.Execute(env.Get()); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Environment Variable Conflict and Execution Order Issues

The env command's new logic for setting an environment introduces a local env variable that shadows the imported package, causing compilation errors for env.Contains, env.Set, and env.Execute. Additionally, env.Set() runs before raid.ForceLoad(), which it depends on for context. The command also continues execution without handling errors from raid.ForceLoad() or a failed env.Set().

Fix in Cursor Fix in Web

return file

os.MkdirAll(path.Dir(pathEx), os.ModeDir|0755)
return os.Create(pathEx)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: CreateFile Mode Inconsistency

The CreateFile function has inconsistent behavior: it returns a read-only file handle if the file exists, but a write-only handle if it creates a new file. This means callers cannot rely on a predictable file mode.

Fix in Cursor Fix in Web

@8bitAlex 8bitAlex merged commit 3b69285 into main Oct 2, 2025
7 checks passed
@8bitAlex 8bitAlex deleted the env branch October 2, 2025 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants