Merge pull request #64 in ITERATE/cyberduck from feature/windows/9074 to master
[cyberduck.git] / source / ch / cyberduck / cli / TerminalController.java
blob73cdda612a606fec1c8f6807c4d920f3400a7b8f
1 package ch.cyberduck.cli;
3 /*
4 * Copyright (c) 2002-2014 David Kocher. All rights reserved.
5 * http://cyberduck.io/
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to:
18 * feedback@cyberduck.io
21 import ch.cyberduck.core.AbstractController;
22 import ch.cyberduck.core.Host;
23 import ch.cyberduck.core.ProgressListener;
24 import ch.cyberduck.core.TranscriptListener;
25 import ch.cyberduck.core.exception.BackgroundException;
26 import ch.cyberduck.core.threading.MainAction;
28 /**
29 * @version $Id$
31 public class TerminalController extends AbstractController {
33 private TranscriptListener transcript;
35 private ProgressListener progress;
37 public TerminalController(final ProgressListener progress,
38 final TranscriptListener transcript) {
39 this.transcript = transcript;
40 this.progress = progress;
43 @Override
44 public void invoke(final MainAction runnable, final boolean wait) {
45 runnable.run();
48 @Override
49 public boolean alert(final Host host, final BackgroundException failure, final StringBuilder transcript) {
50 return new TerminalAlertCallback().alert(host, failure, transcript);
53 @Override
54 protected void failure(final Exception trace, final Exception failure) {
55 trace.initCause(failure);
56 trace.printStackTrace(System.err);
57 System.exit(1);
60 @Override
61 public void message(final String message) {
62 progress.message(message);
65 @Override
66 public void log(final boolean request, final String message) {
67 transcript.log(request, message);