add --inplace flag #59
No reviewers
Labels
No Label
blocked: dependency
blocked: info-needed
bug
duplicate
enhancement
fixed in HEAD
help wanted
hs:arrows
hs:brackets
hs:classes
hs:comments
hs:do-notation
hs:guards
hs:lists
hs:operators
hs:patterns
hs:records
hs:types
invalid
language extension support
layouting
needs confirmation
priority: high
priority: low
question
revisit before next release
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: hexagoxel/brittany#59
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "master"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
This PR adds support for:
-i
/-o
flags;--inplace
flag as a shortcut for overwriting the input files with the formatted output.I'm still trying to learn Haskell, so suggestions are appreciated 😄 .
Heh, i was just working on brittany too. I want to take a break now, but will have a look at this later.
Looks good! It seems to address all points from #40 apart from the parallelization, which is fine. I have still done some nitpicking :p
Optimally we'd also want to support multiple
inputParam
s, but it seemsbutcher
does allow for that yet.. I should probably fix that.@ -0,0 +126,4 @@
putStrLn $ "Copyright (C) 2016-2017 Lennart Spitzner"
putStrLn $ "There is NO WARRANTY, to the extent permitted by law."
System.Exit.exitSuccess
when printHelp $ do
Any particular reason not to do
Left errNo -> return $ Just ErrNo
?foldM
sure works, but is overkill. You execute the same thing for eachios
element, so i'd say it is more idiomatic to separate the IO and the non-IO: useresults <- sequence ios; let result = _ results
(or make it a one-liner viafmap
).Btw the reason I used
Either e ()
instead ofMaybe e
is that I usually interpretNothing
as the failure-case, but it would be inverted here. But you can fold lists of either (Either or Maybe) into one element usingsequence_
orasum
, respectively.In my opinion the case-of that was above before is nicer. This helper obscures the logic by forcing me to jump half a screen down and back up, with little benefit.
There is another source of redundancy I'd rather focus on: The code above effectively checks
inplace
twice andnull outputPaths
twice as well. Merging those two makes more sense imo.Thanks! It is merged into
dev
branch.I'll add a note to #40.
@lspitzner the reason why I don't exit with
errNo
is that if more files fail then the exit code would depend on the order of the inputs and imo that'd be strange. I can do it if you feel strongly about it.I should have addressed all the other comments though.
I wouldn't have minded depending on the order, but I can understand that you don't like it. In the end you can just not communicate very much in one
Int
. I have merged as-is.Btw by using sequence for the
IO
part, making things parallel should be a one-liner.Pull request closed