1 /* 2 * hunt-console eases the creation of beautiful and testable command line interfaces. 3 * 4 * Copyright (C) 2018-2019, HuntLabs 5 * 6 * Website: https://www.huntlabs.net 7 * 8 * Licensed under the Apache-2.0 License. 9 * 10 */ 11 12 module hunt.console.output.SystemOutput; 13 14 import hunt.console.formatter.OutputFormatter; 15 import std.stdio; 16 import hunt.stream.FileOutputStream; 17 import hunt.console.output.StreamOutput; 18 import hunt.console.output.Verbosity; 19 import hunt.console.output.Output; 20 import hunt.console.output.ConsoleOutput; 21 22 class SystemOutput : StreamOutput , ConsoleOutput 23 { 24 private Output stderr; 25 26 public this() 27 { 28 super(new FileOutputStream(stdout)); 29 initialize(); 30 } 31 32 public this(Verbosity verbosity) 33 { 34 super(new FileOutputStream(stdout), verbosity); 35 initialize(); 36 } 37 38 public this(Verbosity verbosity, bool decorated) 39 { 40 super(new FileOutputStream(stdout), verbosity, decorated); 41 } 42 43 public this(Verbosity verbosity, bool decorated, OutputFormatter formatter) 44 { 45 super(new FileOutputStream(stdout), verbosity, decorated, formatter); 46 } 47 48 private void initialize() 49 { 50 this.stderr = new StreamOutput(new FileOutputStream(std.stdio.stderr)); 51 } 52 53 override public void setDecorated(bool decorated) 54 { 55 super.setDecorated(decorated); 56 stderr.setDecorated(decorated); 57 } 58 59 override public void setFormatter(OutputFormatter formatter) 60 { 61 super.setFormatter(formatter); 62 stderr.setFormatter(formatter); 63 } 64 65 override public void setVerbosity(Verbosity verbosity) 66 { 67 super.setVerbosity(verbosity); 68 stderr.setVerbosity(verbosity); 69 } 70 71 override public Output getErrorOutput() 72 { 73 return stderr; 74 } 75 76 override public void setErrorOutput(Output error) 77 { 78 stderr = error; 79 } 80 }