My favorites | Sign in
Project Logo
                
New issue | Search
for
| Advanced search | Search tips
Issue 222: empty has no effect with file arguments
1 person starred this issue and may be notified of changes. Back to list
Status:  Accepted
Owner:  ----
Type-Defect
Priority-Medium
Proj-CmdArgs


Sign in to add a comment
 
Reported by s.astanin, Sep 30, 2009
What steps will reproduce the problem?

1. cabal install cmdargs
2. run an example from http://community.haskell.org/~ndm/cmdargs/ without
arguments

> $ cat cmdargs.hs 
> {-# LANGUAGE DeriveDataTypeable #-}
> import System.Console.CmdArgs
> data Sample = Sample {hello :: String} deriving (Show, Data, Typeable)
> sample = mode $ Sample{hello = def &= text "World argument" & empty "world"}
> main = print =<< cmdArgs "Sample v1, (C) Neil Mitchell 2009" [sample]
> $ runhaskell cmdargs.hs --hello=Neil
> Sample {hello = "Neil"}
> $ runhaskell cmdargs.hs 
> Sample {hello = ""}

What is the expected output? What do you see instead?

I expected that default value supplied with `empty' to be used to construct
a `Sample'. Something like this:

> Sample {hello = "world"}

What version of the product are you using? On what operating system?
(Saying "latest" is fine, especially for Hoogle web search)

Debian Linux (lenny) i386, GHC 6.10.3, cmdargs-0.1


Comment 1 by ndmitchell, Oct 11, 2009
I believe doing:

> sample = mode $ Sample{hello = "world" &= text "World argument"}

Should work fine. If empty is being ignored I guess I should either use it, or give an 
error message saying it's being ignored. I'll have a think.

Summary: empty has no effect with file arguments
Status: Accepted
Labels: Proj-CmdArgs
Comment 2 by s.astanin, Oct 22, 2009
The workaround, which you suggested, works. Thank you.
Comment 3 by magnus.therning, Oct 30, 2009
This had me confused as well.  Especially when considering the description of `empty`.
Sign in to add a comment

Hosted by Google Code