1 module binders; 2 3 import std.stdio : File; 4 import jaster.cli : ArgBinderFunc, Result; 5 6 /++ 7 + Please review jaster.cli.binder.ArgBinder's documentation for detailed information. 8 + 9 + To be brief: An @ArgBinderFunc is used to convert a string (from the command line) into another type. 10 + 11 + For example, if a command had an arg called "file", and it was of type "File", then an arg binder matching 12 + the following signature is used to perform the conversion: 13 + 14 + Result!File MyArgBinder(string argAsString); 15 + ++/ 16 17 // Arg binder that opens a file in read mode. 18 @ArgBinderFunc 19 Result!File fileBinder(string arg) 20 { 21 try return Result!File.success(File(arg, "r")); 22 catch(Exception) return Result!File.failure("File does not exist."); 23 }