Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Provides parser for $HOME/.netrc
files
The implemented grammar is approximately:
NETRC := (WS|<comment>)* (ENTRY (WS+ <comment>*)+)* ENTRY? ENTRY := 'machine' WS+ <value> WS+ ((account|username|password) WS+ <value>)* | 'default' WS+ (('account'|'username'|'password') WS+ <value>)* | 'macdef' <value> LF (<line> LF)* LF WS := (LF|SPC|TAB) <line> := !LF+ <value> := !WS+ <comment> := '#' !LF* LF
As an extension to the .netrc
-format as described in .e.g.
netrc(5), #
-style comments are
tolerated. Comments are currently only allowed before, between,
and after machine
/default
/macdef
entries. Be aware though
that such #
-comment are not supported by all .netrc
-aware
applications, including ftp(1)
.
Synopsis
- data NetRc = NetRc {
- nrHosts :: [NetRcHost]
- nrMacros :: [NetRcMacDef]
- data NetRcHost = NetRcHost {
- nrhName :: !ByteString
- nrhLogin :: !ByteString
- nrhPassword :: !ByteString
- nrhAccount :: !ByteString
- nrhMacros :: [NetRcMacDef]
- data NetRcMacDef = NetRcMacDef {}
- netRcToBuilder :: NetRc -> Builder
- netRcToByteString :: NetRc -> ByteString
- netRcParsec :: Parser NetRc
- parseNetRc :: SourceName -> ByteString -> Either ParseError NetRc
- readUserNetRc :: IO (Maybe (Either ParseError NetRc))
Types
Represents (semantic) contents of a .netrc
file
NetRc | |
|
Instances
NFData NetRc Source # | |||||
Defined in Network.NetRc | |||||
Data NetRc Source # | |||||
Defined in Network.NetRc gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NetRc -> c NetRc gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NetRc dataTypeOf :: NetRc -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c NetRc) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NetRc) gmapT :: (forall b. Data b => b -> b) -> NetRc -> NetRc gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NetRc -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NetRc -> r gmapQ :: (forall d. Data d => d -> u) -> NetRc -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> NetRc -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> NetRc -> m NetRc gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NetRc -> m NetRc gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NetRc -> m NetRc | |||||
Generic NetRc Source # | |||||
Defined in Network.NetRc
| |||||
Show NetRc Source # | |||||
Eq NetRc Source # | |||||
Ord NetRc Source # | |||||
type Rep NetRc Source # | |||||
Defined in Network.NetRc type Rep NetRc = D1 ('MetaData "NetRc" "Network.NetRc" "netrc-0.2.0.1-inplace" 'False) (C1 ('MetaCons "NetRc" 'PrefixI 'True) (S1 ('MetaSel ('Just "nrHosts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [NetRcHost]) :*: S1 ('MetaSel ('Just "nrMacros") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [NetRcMacDef]))) |
machine
and default
entries describe remote accounts
Invariant: fields must not contain any TAB
s, SPACE
, or LF
s.
NetRcHost | |
|
Instances
NFData NetRcHost Source # | |||||
Defined in Network.NetRc | |||||
Data NetRcHost Source # | |||||
Defined in Network.NetRc gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NetRcHost -> c NetRcHost gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NetRcHost toConstr :: NetRcHost -> Constr dataTypeOf :: NetRcHost -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c NetRcHost) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NetRcHost) gmapT :: (forall b. Data b => b -> b) -> NetRcHost -> NetRcHost gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NetRcHost -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NetRcHost -> r gmapQ :: (forall d. Data d => d -> u) -> NetRcHost -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> NetRcHost -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> NetRcHost -> m NetRcHost gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NetRcHost -> m NetRcHost gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NetRcHost -> m NetRcHost | |||||
Generic NetRcHost Source # | |||||
Defined in Network.NetRc
| |||||
Show NetRcHost Source # | |||||
Eq NetRcHost Source # | |||||
Ord NetRcHost Source # | |||||
Defined in Network.NetRc | |||||
type Rep NetRcHost Source # | |||||
Defined in Network.NetRc type Rep NetRcHost = D1 ('MetaData "NetRcHost" "Network.NetRc" "netrc-0.2.0.1-inplace" 'False) (C1 ('MetaCons "NetRcHost" 'PrefixI 'True) ((S1 ('MetaSel ('Just "nrhName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: S1 ('MetaSel ('Just "nrhLogin") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString)) :*: (S1 ('MetaSel ('Just "nrhPassword") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: (S1 ('MetaSel ('Just "nrhAccount") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: S1 ('MetaSel ('Just "nrhMacros") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [NetRcMacDef]))))) |
data NetRcMacDef Source #
macdef
entries defining ftp
macros
Instances
NFData NetRcMacDef Source # | |||||
Defined in Network.NetRc rnf :: NetRcMacDef -> () | |||||
Data NetRcMacDef Source # | |||||
Defined in Network.NetRc gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NetRcMacDef -> c NetRcMacDef gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NetRcMacDef toConstr :: NetRcMacDef -> Constr dataTypeOf :: NetRcMacDef -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c NetRcMacDef) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NetRcMacDef) gmapT :: (forall b. Data b => b -> b) -> NetRcMacDef -> NetRcMacDef gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NetRcMacDef -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NetRcMacDef -> r gmapQ :: (forall d. Data d => d -> u) -> NetRcMacDef -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> NetRcMacDef -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> NetRcMacDef -> m NetRcMacDef gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NetRcMacDef -> m NetRcMacDef gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NetRcMacDef -> m NetRcMacDef | |||||
Generic NetRcMacDef Source # | |||||
Defined in Network.NetRc
from :: NetRcMacDef -> Rep NetRcMacDef x to :: Rep NetRcMacDef x -> NetRcMacDef | |||||
Show NetRcMacDef Source # | |||||
Defined in Network.NetRc showsPrec :: Int -> NetRcMacDef -> ShowS show :: NetRcMacDef -> String showList :: [NetRcMacDef] -> ShowS | |||||
Eq NetRcMacDef Source # | |||||
Defined in Network.NetRc (==) :: NetRcMacDef -> NetRcMacDef -> Bool (/=) :: NetRcMacDef -> NetRcMacDef -> Bool | |||||
Ord NetRcMacDef Source # | |||||
Defined in Network.NetRc compare :: NetRcMacDef -> NetRcMacDef -> Ordering (<) :: NetRcMacDef -> NetRcMacDef -> Bool (<=) :: NetRcMacDef -> NetRcMacDef -> Bool (>) :: NetRcMacDef -> NetRcMacDef -> Bool (>=) :: NetRcMacDef -> NetRcMacDef -> Bool max :: NetRcMacDef -> NetRcMacDef -> NetRcMacDef min :: NetRcMacDef -> NetRcMacDef -> NetRcMacDef | |||||
type Rep NetRcMacDef Source # | |||||
Defined in Network.NetRc type Rep NetRcMacDef = D1 ('MetaData "NetRcMacDef" "Network.NetRc" "netrc-0.2.0.1-inplace" 'False) (C1 ('MetaCons "NetRcMacDef" 'PrefixI 'True) (S1 ('MetaSel ('Just "nrmName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: S1 ('MetaSel ('Just "nrmBody") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString))) |
Formatters
netRcToBuilder :: NetRc -> Builder Source #
Construct a ByteString
Builder
netRcToByteString :: NetRc -> ByteString Source #
Format NetRc
into a ByteString
This is currently just a convenience wrapper around netRcToBuilder
Parsers
netRcParsec :: Parser NetRc Source #
Text.Parsec.ByteString Parser
for .netrc
grammar
parseNetRc :: SourceName -> ByteString -> Either ParseError NetRc Source #
Convenience wrapper for netRcParsec
parser
This is basically just
parseNetRc
=parse
(netRcParsec
<*eof
)
This wrapper is mostly useful for avoiding to have to import Parsec
modules (and to build-depend explicitly on parsec
).
Utilities
readUserNetRc :: IO (Maybe (Either ParseError NetRc)) Source #
Reads and parses default $HOME/.netrc
Returns Nothing
if $HOME
variable undefined and/or if .netrc
if missing.
Throws standard IO exceptions in case of other filesystem-errors.
Note: This function performs no permission sanity-checking on
the .netrc
file