Skip to content

Commit f9cbff8

Browse files
committed
Implemented initial argument logic.
Moved sources. Changed main module names to Main.
1 parent 3ca7e1b commit f9cbff8

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

diffr.cabal

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ Build-Type: Simple
99
Cabal-Version: >=1.2
1010

1111
Executable diffr
12-
Main-is: diff/Main.hs
13-
Build-Depends: base
12+
Main-is: src/diffr/diff/Main.hs
13+
Build-Depends: base >= 4
14+
ghc-options: -Wall
1415

1516
Executable patchr
16-
Main-is: patch/Main.hs
17-
Build-Depends: base
17+
Main-is: src/diffr/patch/Main.hs
18+
Build-Depends: base >= 4
19+
ghc-options: -Wall

diff/Main.hs renamed to src/diffr/diff/Main.hs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{- |
2-
Module : Diffr.Main
2+
Module : Main
33
Description : Main entry point for diffr.
4-
Since : 0.0
4+
Since : 0.1
55
Authors : William Martin
66
License : This file is part of diffr-h.
77
@@ -18,12 +18,27 @@
1818
along with diffr-h. If not, see <http://www.gnu.org/licenses/>.
1919
-}
2020

21-
module Diffr.Main where
21+
module Main ( main ) where
2222

23-
import System.Environment
23+
import System.Environment( getArgs )
24+
import System.Exit ( exitFailure, exitSuccess )
2425

2526
-- | 'main' runs the main program
2627
main :: IO ()
27-
main = print usage
28+
main = do
29+
args <- getArgs
30+
if not ( 2 == length args || 4 == length args )
31+
then do
32+
printUsage
33+
exitFailure
34+
else do
35+
print ( length args )
36+
exitSuccess
2837

29-
usage = "diffr says hello"
38+
39+
40+
-- | 'printUsage' prints the usage information for diffr.
41+
printUsage :: IO ()
42+
printUsage = putStrLn ( "Usage: \n" ++
43+
" diffr <original-file> <new-file>\n" ++
44+
" diffr <original-file> <new-file> -o <output-file>" )

patch/Main.hs renamed to src/diffr/patch/Main.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{- |
2-
Module : Patchr.Main
2+
Module : Main
33
Description : Main entry point for patchr.
4-
Since : 0.0
4+
Since : 0.1
55
Authors : William Martin
66
License : This file is part of diffr-h.
77
@@ -18,7 +18,7 @@
1818
along with diffr-h. If not, see <http://www.gnu.org/licenses/>.
1919
-}
2020

21-
module Patchr.Main where
21+
module Main where
2222

2323
import System.Environment
2424

0 commit comments

Comments
 (0)