Pathy.Printer
- Package
- pathy
- Repository
- id3as/purescript-pathy
#Printer Source
type Printer = { current :: NonEmptyString, escaper :: Escaper, root :: Maybe NonEmptyString -> String, sep :: NonEmptyString, up :: NonEmptyString }
A Printer
defines options for printing paths.
root
is a function used to construct the initial segment of paths.current
is a representation of the current directory.up
is a representation of going up to the parent directory.sep
is the string to separate path segments by.escaper
specified how to deal with printing reserved names and characters.
#posixPrinter Source
posixPrinter :: Printer
A printer for POSIX paths.
#windowsPrinter Source
windowsPrinter :: Printer
A printer for Windows paths.
#printPath Source
printPath :: forall a b. IsRelOrAbs a => IsDirOrFile b => Printer -> SandboxedPath a b -> String
Prints a SandboxedPath
into its canonical String
representation, using
the specified printer. The printed path will always be absolute, as this
is the only way to ensure the path is safely referring to the intended
location.
#unsafePrintPath Source
unsafePrintPath :: forall a b. IsRelOrAbs a => IsDirOrFile b => Printer -> SandboxedPath a b -> String
Prints a SandboxedPath
into its canonical String
representation, using
the specified printer. This will print a relative path if b ~ Rel
, which
depending on how the resulting string is used, may be unsafe.
#debugPrintPath Source
debugPrintPath :: forall a b. Warn (Text "debugPrintPath usage") => IsRelOrAbs a => IsDirOrFile b => Printer -> Path a b -> String
Prints a path exactly according to its representation. This should only be used for debug purposes. Using this function will raise a warning at compile time as a reminder!
#Escaper Source
newtype Escaper
An Escaper
encodes segments or characters which have reserved meaning
within names in a path.
Constructors
Instances
#slashEscaper Source
slashEscaper :: Escaper
An escaper that replaces all '/'
characters in a name with '-'
s.
#dotEscaper Source
dotEscaper :: Escaper
An escaper that replaces names "."
and ".."
with "$dot"
and
"$dot$dot"
.
#posixEscaper Source
posixEscaper :: Escaper
An escaper that removes all slashes, converts ".." into "$dot$dot", and converts "." into "$dot".
#windowsEscaper Source
windowsEscaper :: Escaper
An escaper that attempts to encode all reserved names and characters for windows-style paths.