cmdArgsReform :: Mode (CmdArgs a) -> CmdArgs a -> [String]
Given a mode, and a value (presumably returned by cmdArgs or similar, perhaps tweaked slightly) it will give a set of arguments, which when parsed with the given mode, will regenerate the value.
Use case: For servers, it's useful to run them in a mode that continually respawns them if they die. This can usually be done by passing --restart, then running the same program with all but the --restart argument. With cmdArgsReform you parse with CmdArgs, and on seeing the restart just set it to false, and manufacture a new set of equivalent arguments.
Implementation notes: I probably need to add modeReform :: Maybe (a -> [String]) to the mode constructor. During construction we have to manufacture this function, then cmdArgsReform just calls it.
Testing: Testing is rather easy, I just add to the test case driver a test, so it will always get tested that if you run this you get back what you started with.
From http://code.google.com/p/ndmitchell/issues/detail?id=404:
It would be useful to add the function:
Given a mode, and a value (presumably returned by cmdArgs or similar, perhaps tweaked slightly) it will give a set of arguments, which when parsed with the given mode, will regenerate the value.
Use case: For servers, it's useful to run them in a mode that continually respawns them if they die. This can usually be done by passing --restart, then running the same program with all but the --restart argument. With cmdArgsReform you parse with CmdArgs, and on seeing the restart just set it to false, and manufacture a new set of equivalent arguments.
Implementation notes: I probably need to add modeReform :: Maybe (a -> [String]) to the mode constructor. During construction we have to manufacture this function, then cmdArgsReform just calls it.
Testing: Testing is rather easy, I just add to the test case driver a test, so it will always get tested that if you run this you get back what you started with.