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.input.Input; 13 14 import hunt.console.error.InvalidArgumentException; 15 import hunt.console.input.InputDefinition; 16 17 18 abstract class Input 19 { 20 string getFirstArgument(); 21 22 bool hasParameterOption(string value, bool onlyParams = false) { 23 return hasParameterOption([value], onlyParams); 24 } 25 26 bool hasParameterOption(string[] values, bool onlyParams = false); 27 28 string getParameterOption(string value, bool onlyParams = false) { 29 return getParameterOption([value], null, onlyParams); 30 } 31 32 string getParameterOption(string value, string defaultValue, bool onlyParams = false) { 33 return getParameterOption([value], defaultValue, onlyParams); 34 } 35 36 string getParameterOption(string[] values, string defaultValue, bool onlyParams = false); 37 // string getParameterOption(string value); 38 39 // string getParameterOption(string value, string defaultValue); 40 41 void bind(InputDefinition definition); 42 43 void validate() /* throws RuntimeException */; 44 45 string[] getArguments(); 46 47 string getArgument(string name); 48 49 void setArgument(string name, string value) /* throws InvalidArgumentException */; 50 51 bool hasArgument(string name); 52 53 string[] getOptions(); 54 55 string getOption(string name); 56 57 void setOption(string name, string value) /* throws InvalidArgumentException */; 58 59 bool hasOption(string name); 60 61 bool isInteractive(); 62 63 void setInteractive(bool interactive); 64 }