Skip to content
Open
Show file tree
Hide file tree
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
56 changes: 49 additions & 7 deletions scripts/cli/lec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ _printHelpAndExit() {
stop Stop a Composer project
clean Stop a Composer project and remove Docker volumes
exportData Export container data for a Composer project
list [resource] List resources of a specified type
remove Completely tear down and remove a Composer project
share [--export] Save a Composer workspace for sharing. The "--export" flag exports the container data before saving the workspace.
update [--unstable] Check for updates to Composer and lec. The "--unstable" flag updates to latest master branch.
Expand Down Expand Up @@ -336,6 +337,11 @@ _verifyCommand() {

_listPublicCommands | grep -q "^${command}$"
}
_verifyListResource() {
local resource="${1}"

_listPrefixedFunctions _list_ | grep -wq "${resource}"
}

#
# General helper functions
Expand Down Expand Up @@ -364,6 +370,18 @@ _getWorktreeDir() {

_listWorktrees | grep "/${worktree_name}$"
}
_list_releases() {
_listReleases
}
_list_runningProjects() {
_listRunningProjects
}
_list_saasEnvironments() {
_listSaaSEnvironments
}
_list_worktrees() {
_listWorktrees
}
_removeWorktree() {
local worktree="${1:?Worktree directory required}"

Expand Down Expand Up @@ -476,6 +494,9 @@ _cmd_commands() {
printf "\n${C_BOLD}%s${C_RESET}\n\n" "Private Commands:"
_listPrivateCommands | sed 's,^, ,g'
}
_cmd_fn() {
"${1}" "${@:2}"
}
_cmd_gw() {
_checkCWDProject

Expand All @@ -485,14 +506,35 @@ _cmd_gw() {
./gradlew "${@}"
)
}
_cmd_fn() {
"${1}" "${@:2}"
}
_cmd_list() {
_listWorktrees
}
_cmd_listRunning() {
_listRunningProjects
local closest_resource
local resource="${1}"

if [[ ${resource} == "" ]]; then
_print_step "Listing valid resources..."

_listPrefixedFunctions _list_

exit
fi

if ! _verifyListResource "${resource}"; then
closest_resource=$(_listPrefixedFunctions _list_| _fzf --filter "${resource}" | head -n 1)

if _verifyListResource "${closest_resource}" && _confirm "Resource \"${resource}\" is unknown; use closest resource \"${closest_resource}\" instead?"; then
resource=${closest_resource}
else
_print_error "Resource \"${resource}\" is invalid. Listing valid resources..."

_listPrefixedFunctions _list_

exit
fi
fi

_print_step "Listing all ${resource//_/ }"

_list_"${resource}"
}
_cmd_ports() {
local serviceName="${1}"
Expand Down
2 changes: 1 addition & 1 deletion scripts/cli/shell-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function lecd() {

local worktree_dir
worktree_dir="$(
lec list |
lec list worktrees |
fzf \
--delimiter "/" \
--exit-0 \
Expand Down