Skip to content

Commit

Permalink
chore: rename cli (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettladley authored Apr 15, 2024
1 parent a911f1f commit 109c5ae
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.DS_Store

# Cli
sac-cli
sac

# VSCode
.vscode
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@

### SAC CLI

To install use `./install.sh` and then run `sac-cli` to see all commands.
To install use `./install.sh` and then run `sac` to see all commands.

# Git Flow

Expand Down
2 changes: 1 addition & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func main() {
app := &cli.App{
Name: "sac-cli",
Name: "sac",
Usage: "CLI for the GenerateNU SAC",
Commands: []*cli.Command{
commands.SwaggerCommand(),
Expand Down
12 changes: 6 additions & 6 deletions cli/utils/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func GetRootDir() (string, error) {
return "", err
}

// Find the closest directory containing "sac-cli" (the root directory)
// Find the closest directory containing "sac" (the root directory)
rootDir, err := FindRootDir(currentDir)
if err != nil {
return "", err
Expand All @@ -23,19 +23,19 @@ func GetRootDir() (string, error) {
}

func FindRootDir(dir string) (string, error) {
// Check if "sac-cli" exists in the current directory
mainGoPath := filepath.Join(dir, "sac-cli")
// Check if "sac" exists in the current directory
mainGoPath := filepath.Join(dir, "sac")
_, err := os.Stat(mainGoPath)
if err == nil {
// "sac-cli" found, this is the root directory
// "sac" found, this is the root directory
return dir, nil
}

// If not found, go up one level
parentDir := filepath.Dir(dir)
if parentDir == dir {
// Reached the top without finding "sac-cli"
return "", fmt.Errorf("could not find root directory containing sac-cli")
// Reached the top without finding "sac"
return "", fmt.Errorf("could not find root directory containing sac")
}

// Recursively search in the parent directory
Expand Down
14 changes: 7 additions & 7 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
$ScriptPath = (Get-Item -Path $MyInvocation.MyCommand.Path).DirectoryName

# Build the Go CLI tool
go build -o "sac-cli" "cli/main.go"
go build -o "sac" "cli/main.go"

# Check if sac-cli is already installed
if (Test-Path -Path "$Env:USERPROFILE\AppData\Local\Programs\sac-cli\sac-cli.exe") {
# Check if sac is already installed
if (Test-Path -Path "$Env:USERPROFILE\AppData\Local\Programs\sac\sac.exe") {
exit 1
}

# Copy the sac-cli executable to a directory in the user's PATH
$InstallPath = "$Env:USERPROFILE\AppData\Local\Programs\sac-cli"
# Copy the sac executable to a directory in the user's PATH
$InstallPath = "$Env:USERPROFILE\AppData\Local\Programs\sac"
if (-not (Test-Path -Path $InstallPath)) {
New-Item -ItemType Directory -Path $InstallPath | Out-Null
}
Copy-Item -Path "sac-cli" -Destination "$InstallPath\sac-cli.exe" -Force
Copy-Item -Path "sac" -Destination "$InstallPath\sac.exe" -Force

# Add the installation path to the user's PATH
$PathEnvVar = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User)
Expand All @@ -23,4 +23,4 @@ if (-not ($PathEnvVar -like "*$InstallPath*")) {
}

# Inform the user
Write-Host "Installation complete. You can now run 'sac-cli' from anywhere."
Write-Host "Installation complete. You can now run 'sac' from anywhere."
8 changes: 4 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ set -o pipefail
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Build the Go CLI tool
go build -o "sac-cli" "cli/main.go"
go build -o "sac" "cli/main.go"

# Identify the user's shell
SHELL_NAME=$(basename "$SHELL")

# Check if the command is already installed to avoid adding it to path multiple times
COMMAND_NAME="sac-cli"
COMMAND_NAME="sac"

if command -v "$COMMAND_NAME" >/dev/null 2>&1; then
exit 1
fi

# Add sac-cli to the user's PATH
# Add sac to the user's PATH
if [[ $SHELL_NAME == "zsh" ]]; then
echo "export PATH=\"$SCRIPT_PATH:\$PATH\"" >>~/.zshrc
source ~/.zshrc
Expand All @@ -32,4 +32,4 @@ else
fi

# Inform the user
echo "Installation complete. You can now run 'sac-cli' from anywhere."
echo "Installation complete. You can now run 'sac' from anywhere."

0 comments on commit 109c5ae

Please sign in to comment.