diff --git a/README.md b/README.md index c7d9f76..b29ae11 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,17 @@ To run the tests: ```bash python -m pytest ``` +### Troubleshooting + +#### Error: File "setup.py" not found. +If you get this error when running: + +> ERROR: File "setup.py" not found. Directory cannot be installed in editable mode: ... +(A "pyproject.toml" file was found, but editable mode currently requires a setup.py based build.) + +it usually means you need to upgrade pip to version 21.3 or newer +``` +pip install --upgrade pip +``` + + diff --git a/arm_cli/container/container.py b/arm_cli/container/container.py index 3d970b1..456ec92 100644 --- a/arm_cli/container/container.py +++ b/arm_cli/container/container.py @@ -7,7 +7,7 @@ @click.group() def container(): - """Manage Docker containers""" + """Basic tools for managing Docker containers. For more extensive tooling, try lazydocker""" pass @@ -60,6 +60,44 @@ def attach_container(): print("\nExiting interactive session...") +@container.command("restart") +def restart_container(): + """Interactively select a running Docker container and restart it""" + containers = get_running_containers() + + if not containers: + print("No running containers found.") + return + + container_choices = [ + inquirer.List( + "container", + message="Select a container to restart", + choices=[f"{container.name} ({container.id[:12]})" for container in containers], + carousel=True, + ) + ] + + answers = inquirer.prompt(container_choices) + if not answers: + print("No container selected.") + return + + selected_container_name = answers["container"].split(" ")[0] + + print(f"Restarting {selected_container_name}...") + + try: + client = docker.from_env() + container = client.containers.get(selected_container_name) + container.restart() + print(f"Container {selected_container_name} restarted successfully.") + except docker.errors.NotFound: + print(f"Error: Container {selected_container_name} not found.") + except docker.errors.APIError as e: + print(f"Error restarting container: {e}") + + @container.command("stop") def stop_container(): """Interactively select a running Docker container and stop it""" diff --git a/arm_cli/system/shell_scripts/shell_addins.fish b/arm_cli/system/shell_scripts/shell_addins.fish index 130369a..c2d24b1 100644 --- a/arm_cli/system/shell_scripts/shell_addins.fish +++ b/arm_cli/system/shell_scripts/shell_addins.fish @@ -1,3 +1,6 @@ # Setup autocomplete -_ARM_CLI_COMPLETE=fish_source arm-cli | source \ No newline at end of file +_ARM_CLI_COMPLETE=fish_source arm-cli | source + +# Export for use when launching Docker to match host file ownership +set -x CURRENT_UID (id -u):(id -g) diff --git a/arm_cli/system/shell_scripts/shell_addins.sh b/arm_cli/system/shell_scripts/shell_addins.sh index 6d3b26f..d3ba667 100644 --- a/arm_cli/system/shell_scripts/shell_addins.sh +++ b/arm_cli/system/shell_scripts/shell_addins.sh @@ -2,7 +2,7 @@ ## Setup autocomplete # TODO: We can speed this up by generating the script offline. See https://click.palletsprojects.com/en/stable/shell-completion/ if type arm-cli >/dev/null 2>&1; then - eval "$(_ARM_CLI_COMPLETE=source arm-cli)" # TODO: This needs to change to eval "$(_ARM_CLI_COMPLETE=source arm-cli)" at some version. + eval "$(_ARM_CLI_COMPLETE=bash_source arm-cli)" fi @@ -11,8 +11,11 @@ alias_name="aa" cli_path=$(which arm-cli) # Create the alias if the cli was found -# TODO: Unfortunately, tab complete doesn't work when using the alias. Need to investigate a workaround if [ -n "$cli_path" ]; then - alias $alias_name='$cli_path' + alias $alias_name="$cli_path" fi +# TODO: Figure out tab complete for the alias + +# Export for use when launching Docker to match host file ownership +export CURRENT_UID=$(id -u):$(id -g) diff --git a/arm_cli/system/shell_scripts/shell_addins.zsh b/arm_cli/system/shell_scripts/shell_addins.zsh index a9d956e..5a008d4 100644 --- a/arm_cli/system/shell_scripts/shell_addins.zsh +++ b/arm_cli/system/shell_scripts/shell_addins.zsh @@ -1,3 +1,6 @@ # Setup autocomplete -eval "$(_ARM_CLI_COMPLETE=zsh_source arm-cli)"" \ No newline at end of file +eval "$(_ARM_CLI_COMPLETE=zsh_source arm-cli)" + +# Export for use when launching Docker to match host file ownership +export CURRENT_UID=$(id -u):$(id -g) diff --git a/pyproject.toml b/pyproject.toml index 3933b4a..416211e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "arm-cli" -version = "0.1" +version = "0.1.1" description = "Experimental CLI for deploying robotic applications" readme = "README.md" authors = [{name = "Matthew Powelson"}] @@ -18,7 +18,7 @@ dependencies = [ ] [build-system] -requires = ["setuptools"] +requires = ["setuptools>=61.0", "wheel"] build-backend = "setuptools.build_meta" [tool.setuptools.package-data]