Skip to content
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

chore: rename cli #545

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
done
garrettladley committed Apr 15, 2024
commit b58b102aa82880192e605a6b12aeb7f15d42307e
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
.DS_Store

# Cli
sac-cli
sac

# VSCode
.vscode
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
@@ -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(),
12 changes: 6 additions & 6 deletions cli/utils/path.go
Original file line number Diff line number Diff line change
@@ -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
@@ -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
14 changes: 7 additions & 7 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -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)
@@ -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
@@ -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
@@ -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."