Safe Haskell | None |
---|---|
Language | Haskell2010 |
Utilities for application metadata and application-specific filepaths.
API
Links
Synopsis
- data ApplicationInterface
- data DesktopPlatform
- data ApplicationInformation0 = ApplicationInformation0 {}
- data ApplicationInformation = ApplicationInformation {}
- defaultApplicationInformation :: ApplicationInformation0 -> ApplicationInformation
- defaultApplicationInformation0 :: ApplicationInformation0
- currentDesktopPlatform :: Maybe DesktopPlatform
- allDesktopPlatforms :: [DesktopPlatform]
- posixDesktopPlatforms :: [DesktopPlatform]
- getApplicationSpecificConfigFile :: ApplicationInformation -> FilePath -> IO FilePath
- getApplicationSpecificDataFile :: ApplicationInformation -> FilePath -> IO FilePath
- getApplicationSpecificCacheFile :: ApplicationInformation -> FilePath -> IO FilePath
- getApplicationSpecificRuntimeFile :: ApplicationInformation -> FilePath -> IO FilePath
- getApplicationSpecificConfigurationDirectory :: ApplicationInformation -> IO FilePath
- getApplicationSpecificDataDirectory :: ApplicationInformation -> IO FilePath
- getApplicationSpecificCacheDirectory :: ApplicationInformation -> IO FilePath
- getApplicationSpecificRuntimeDirectory :: ApplicationInformation -> IO FilePath
- readApplicationSpecificConfigFile :: ApplicationInformation -> FilePath -> IO (Maybe Text)
- readApplicationSpecificDataFile :: ApplicationInformation -> FilePath -> IO (Maybe Text)
- readApplicationSpecificCacheFile :: ApplicationInformation -> FilePath -> IO (Maybe Text)
- writeApplicationSpecificConfigFile :: ApplicationInformation -> FilePath -> Text -> IO ()
- writeApplicationSpecificDataFile :: ApplicationInformation -> FilePath -> Text -> IO ()
- writeApplicationSpecificCacheFile :: ApplicationInformation -> FilePath -> Text -> IO ()
- listApplicationSpecificDataFiles :: ApplicationInformation -> IO [FilePath]
- removeApplicationSpecificCache :: ApplicationInformation -> IO FilePath
- touchApplicationSpecificRuntimeFile :: ApplicationInformation -> FilePath -> IO Bool
- getApplicationSpecificXdgDirectory :: XdgDirectory -> ApplicationInformation -> FilePath -> IO FilePath
- currentApplicationSpecificSubDirectory :: ApplicationInformation -> FilePath
- readTextFileWith :: IO FilePath -> IO (Maybe Text)
- writeTextFileWith :: IO FilePath -> Text -> IO ()
- getPathFromEnvironmentOrDefault :: IO FilePath -> String -> IO FilePath
- isValidEnvironmentVariableName :: String -> Bool
- asExecutableName :: String -> String
- asPosixDirectory :: String -> String -> String
- asWindowsDirectory :: String -> String -> String
- asMacintoshDirectory :: String -> String -> String
- convertSpacesToHyphens :: String -> String
Documentation
data ApplicationInterface Source #
The kind of application interface.
Cases:
ApplicationCLI
— the application has a Command-Line Interface.ApplicationGUI
— the application has a Graphical-User Interface.
Instances
data DesktopPlatform Source #
Platform for desktop applications.
Instances
data ApplicationInformation0 Source #
The primary fields of ApplicationInformation
, from which the rest are derived (via defaultApplicationInformation
).
Required fields share type with their namesake field (implicitly under Identity
).
Optional fields are wrapped under Maybe
.
Instances
data ApplicationInformation Source #
Metadata for a (cross-platform) application.
Fields
Metadata:
$sel:name:ApplicationInformation
— The name of the application. In english, should be capitalized and have spaces.$sel:version:ApplicationInformation
— The application's (current) version. Should be parseable bybase
'sparseVersion
(custom development versions, like injecting a git commit, should be separated from the version numbers by a hyphen).$sel:license:ApplicationInformation
— The application's license. Should be an SPDX License Identifier.$sel:executable:ApplicationInformation
— The basename (or shell identifier) of the executable file. Should match theexecutable
stanza in the package's.cabal
. For legibility and portability, words should be separated by hyphens (i.e.-
) or underscores (i.e._
).$sel:interface:ApplicationInformation
— Whether the application has a Command-Line Interface or a Graphical-User Interface.
Platform-specific metadata:
$sel:platforms:ApplicationInformation
— Supported platforms (i.e. that the application is known to run on).$sel:posixDirectory:ApplicationInformation
— .$sel:windowsDirectory:ApplicationInformation
— .$sel:macintoshDirectory:ApplicationInformation
— .
Example
e.g.:
myApplicationInformation :: ApplicationInformation myApplicationInformation =ApplicationInformation
{..} where$sel:name:ApplicationInformation
= "My Application"$sel:version:ApplicationInformation
= "0.0.0"$sel:license:ApplicationInformation
= "GPL-3.0-or-later"$sel:vendor:ApplicationInformation
= "sboosali.io"$sel:executable:ApplicationInformation
= "my-application"$sel:interface:ApplicationInformation
=ApplicationCLI
$sel:platforms:ApplicationInformation
=allDesktopPlatforms
-- [DesktopLinux
,DesktopWindows
,DesktopMacintosh
]$sel:posixDirectory:ApplicationInformation
= "myapplication/"$sel:windowsDirectory:ApplicationInformation
= "sboosaliMy Application"$sel:macintoshDirectory:ApplicationInformation
= "io.sboosali.My-Application/"
ApplicationInformation | |
|
Instances
defaultApplicationInformation0 :: ApplicationInformation0 Source #
Required fields are ""
. Optional fields are Nothing
.
writeApplicationSpecificConfigFile :: ApplicationInformation -> FilePath -> Text -> IO () Source #
writeApplicationSpecificDataFile :: ApplicationInformation -> FilePath -> Text -> IO () Source #
writeApplicationSpecificCacheFile :: ApplicationInformation -> FilePath -> Text -> IO () Source #
getApplicationSpecificXdgDirectory :: XdgDirectory -> ApplicationInformation -> FilePath -> IO FilePath Source #
the input FilePath
must be strictly relative. i.e.:
- no
../
writeTextFileWith :: IO FilePath -> Text -> IO () Source #
Creates any (non-existant) parent directories
(in Bash, like a mkdir -p
on the dirname
).
asExecutableName :: String -> String Source #
Construct a $sel:executable:ApplicationInformation
from a $sel:name:ApplicationInformation
.
Examples
>>>
asExecutableName "My Application"
"my-application"
asPosixDirectory :: String -> String -> String Source #
Construct a $sel:posixDirectory:ApplicationInformation
from a $sel:name:ApplicationInformation
.
Examples
>>>
import qualified Prelude
>>>
asPosixDirectory "My Application" Prelude.undefined
"myapplication/"
asWindowsDirectory :: String -> String -> String Source #
Construct a $sel:windowsDirectory:ApplicationInformation
from a $sel:vendor:ApplicationInformation
and a $sel:name:ApplicationInformation
.
Examples
>>>
asWindowsDirectory "My Application" "www.sboosali.com"
"sboosali/My Application/"
asMacintoshDirectory :: String -> String -> String Source #
Construct a $sel:macintoshDirectory:ApplicationInformation
from a $sel:vendor:ApplicationInformation
and a $sel:name:ApplicationInformation
.
Examples
>>>
asMacintoshDirectory "My Application" "www.sboosali.com"
"com.sboosali.www.My-Application/"
convertSpacesToHyphens :: String -> String Source #
Convert multiple whitespace characters to a single hyphen character.
Examples
>>>
convertSpacesToHyphens " phrase with spaces "
"phrase-with-spaces"