Skip to content

Commit 0e68ff7

Browse files
committed
Added detach keys to up command
Finished README.md of the repo
1 parent 346211f commit 0e68ff7

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,14 @@ Update:
6868
- Help: Update the contents of the containers.
6969
- Description: This command will either delete a service or add a service with the same method as Create.
7070
- Arguments:
71-
- --add: Flag to state the addition of a service.
72-
- --remove: Flag to state the removal of a service.
71+
- --add: Flag to state the addition of a new service.
72+
- --remove: Flag to state the removal of an existing service.
73+
- --change: Flag to state the change of an existing service.
7374
- --service: Parameter to specify the name of the service.
7475

76+
> [!NOTE]
77+
> For an update to take place containers must be restarted
78+
7579
Build:
7680
- Help: Build the files for the containerization.
7781
- Description: This command will build the files based on `data.json` in case they were not built when running create.
@@ -87,7 +91,8 @@ Backup:
8791
Up:
8892
- Help: Build the containers and start them. (This will overwrite the data inside with the host data)
8993
- Arguments:
90-
- --atached: Flag to run the containers in atached mode.
94+
- --attached: Flag to run the containers in attached mode.
95+
- --detach-keys: Combination of keys to detach from the container terminal
9196

9297
Down:
9398
- Help: Stop the containers and delete them.
@@ -99,14 +104,18 @@ Down:
99104
100105
Start:
101106
- Help: Start the containers.
102-
- Description: This command will
103107

104108
Stop:
105109
- Help: Stop the containers.
106-
- Description: This command will
107110

108111
Open:
109-
-
112+
- Help: Open the terminal of a service.
113+
- Arguments:
114+
- --service: Name of the service who's container terminal will be opened
115+
- --detach-keys: Combination of keys to detach from the container terminal
116+
117+
> [!WARNING]
118+
> If you attach to a container terminal and detach with `ctrl+c` this will stop the container.
110119
111120
## **Tips & Troubleshooting**
112121
- Ensure Docker Desktop is running and you can run `docker ps` without errors before invoking the CLI.

src/cli/manager.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def open(self) -> Command:
3333
),
3434
]
3535

36-
def callback(service: str, detach_keys: str) -> None:
36+
def callback(service: str, detach_keys: str = "ctrl-p,ctrl-q") -> None:
3737
self.compose_manager.open_terminal(service, detach_keys)
3838

3939
return Command(
@@ -60,10 +60,17 @@ def callback() -> None:
6060

6161
def up(self) -> Command:
6262
help = "Start up the containers after changes."
63-
options = [Option(["--attached"], is_flag=True, default=False)]
63+
options = [
64+
Option(["--attached"], is_flag=True, default=False),
65+
Option(
66+
["--detach-keys"],
67+
type=self.detach_keys_type,
68+
default="ctrl-p,ctrl-q",
69+
),
70+
]
6471

65-
def callback(attached: bool = False) -> None:
66-
self.compose_manager.up(attached)
72+
def callback(attached: bool = False, detach_keys: str = "ctrl-p,ctrl-q") -> None:
73+
self.compose_manager.up(attached, detach_keys)
6774

6875
return Command(
6976
name=inspect.currentframe().f_code.co_name, # type: ignore

src/core/docker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,15 @@ def down(self, remove_volumes: bool = False) -> CompletedProcess[str]:
7575
return self.__run(*args)
7676

7777
@yaspin(text="Putting Up Container...", color="cyan")
78-
def up(self, attached: bool = True) -> CompletedProcess[str]:
78+
def up(self, attached: bool = True, detach_keys: str = "ctrl-p,ctrl-q") -> CompletedProcess[str]:
7979
sleep(self.sleep)
8080

8181
args = ["up", "--build"]
8282
if not attached:
83-
args.extend(["-d"])
83+
args.append("-d")
84+
else:
85+
args.extend(["--detach-keys", detach_keys])
86+
print(f"Use '{detach_keys}' to detach (press sequentially).\n")
8487
return self.__run(*args)
8588

8689
def open_terminal(

0 commit comments

Comments
 (0)