Created
August 11, 2021 05:34
-
-
Save doyle-flutter/5b7801a6668721d864a0f12990368c09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:async'; | |
| import 'dart:io'; | |
| import 'dart:convert'; | |
| void main() async { | |
| bool cmdClose = false; | |
| bool check(String? cmd) => cmd == null || cmd == "F" || cmd.isEmpty; | |
| Future<String> cmd() async{ | |
| String? cmd = stdin.readLineSync(); | |
| if(check(cmd)){ | |
| print("π³ 컨ν μ΄λλ₯Ό μ’ λ£ν©λλ€ π"); | |
| cmdClose = true; | |
| return ""; | |
| } | |
| return cmd ?? ""; | |
| } | |
| stdout.write("π³ 컨ν μ΄λ μ΄λ¦μ μ λ ₯ν΄μ£ΌμΈμ : "); | |
| String containerName = await cmd(); | |
| if(cmdClose) return; | |
| print("π³ 컨ν μ΄λλ₯Ό μ°Ύκ³ μμ΅λλ€ - $containerName"); | |
| var containerCheck = await Process.run('docker', ["ps", "-a"]); | |
| if(containerCheck.stdout.indexOf(containerName) < 0) throw("required Container!!!"); | |
| var dockerPs = await Process.run('docker', ["ps"]); | |
| if(dockerPs.stdout.indexOf(containerName) < 0){ | |
| print('π³ 컨ν μ΄λλ₯Ό μ€νν©λλ€.'); | |
| await Process.run('docker', ["start", containerName]); | |
| } | |
| print('π³ 컨ν μ΄λμ μ°κ²°λμμ΅λλ€ with Dart π―'); | |
| print("π³ 컨ν μ΄λ μ΄λ¦ - $containerName \& ls -al"); | |
| var result = await Process.run('sudo', ["docker", "exec", containerName, "ls", "-al"]); | |
| print(result.stdout); | |
| Future<void> func() async{ | |
| stdout.write("π³ μ€ν ν μμ μ μ λ ₯ν΄μ£ΌμΈμ: "); | |
| String addCmd = await cmd(); | |
| if(cmdClose) return; | |
| var result2 = await Process.run('sudo', ["docker","exec","-i", containerName, ...addCmd.split(" ")]); | |
| print(result2.stdout); | |
| return await func(); | |
| } | |
| await func(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment