protected override async Task <int> OnExecute(CommandLineApplication app) { if (string.IsNullOrEmpty(Host) || string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(Command) ) { ConsoleWriter.Error("\nInvalid command\n"); app.ShowHelp(); return(0); } try { _sshService.Init(Host, Username, Password); await _sshService.ExecuteCommand($"sudo docker {Command}"); _sshService.Dispose(); ConsoleWriter.Success("\nSuccess!"); } catch (Exception ex) { ConsoleWriter.Error(ex.Message); } return(1); }
protected override async Task <int> OnExecute(CommandLineApplication app) { if (string.IsNullOrEmpty(Host) || string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(File) || string.IsNullOrEmpty(Destination) ) { ConsoleWriter.Error("\nInvalid command\n"); app.ShowHelp(); return(0); } try { _sshService.Init(Host, Username, Password); await _sshService.CopyFile(File, Destination); await _sshService.ExecuteCommand($"ls -la {Destination.Substring(0, Destination.LastIndexOf("/"))}"); _sshService.Dispose(); ConsoleWriter.Success("\nSuccess!"); } catch (Exception ex) { ConsoleWriter.Error(ex.Message); } return(1); }