Safe Haskell | None |
---|---|
Language | Haskell2010 |
- Record of information for your application:
- Enumeration of your application's supported platforms.
- Application-specific, XDG-conformant filepaths:
- Read application-specific files.
- Write application-specific files.
$XDG_CONFIG_HOME
utilities:$XDG_DATA_HOME
utilities:$XDG_CACHE_HOME
utilities:$XDG_RUNTIME_HOME
utilities:
Utilities for organizing application metadata and exporting application-specific filepaths.
API
Types:
Functions:
getApplicationSpecificConfigFile
— a.k.a. the${XDG_CONFIG_HOME}
.getApplicationSpecificDataDirectory
— a.k.a. the${XDG_DATA_HOME}
.getApplicationSpecificCacheDirectory
— a.k.a. the${XDG_CACHE_HOME}
.getApplicationSpecificRuntimeDirectory
— a.k.a. the${XDG_RUNTIME_HOME}
.
Usage
Links
Synopsis
- data ApplicationInformation = ApplicationInformation {}
- data ApplicationInformation0 = ApplicationInformation0 {}
- defaultApplicationInformation :: ApplicationInformation0 -> ApplicationInformation
- defaultApplicationInformation0 :: ApplicationInformation0
- asExecutableName :: String -> String
- data ApplicationInterface
- data DesktopPlatform
- allDesktopPlatforms :: [DesktopPlatform]
- currentDesktopPlatform :: Maybe DesktopPlatform
- posixDesktopPlatforms :: [DesktopPlatform]
- asMacintoshDirectory :: String -> String -> String
- asPosixDirectory :: String -> String -> String
- asWindowsDirectory :: String -> String -> String
- getApplicationSpecificConfigFile :: ApplicationInformation -> FilePath -> IO FilePath
- getApplicationSpecificConfigurationDirectory :: ApplicationInformation -> IO FilePath
- getApplicationSpecificDataDirectory :: ApplicationInformation -> IO FilePath
- getApplicationSpecificDataFile :: ApplicationInformation -> FilePath -> IO FilePath
- getApplicationSpecificCacheDirectory :: ApplicationInformation -> IO FilePath
- getApplicationSpecificCacheFile :: ApplicationInformation -> FilePath -> IO FilePath
- getApplicationSpecificRuntimeDirectory :: ApplicationInformation -> IO FilePath
- getApplicationSpecificRuntimeFile :: ApplicationInformation -> FilePath -> IO FilePath
- readApplicationSpecificCacheFile :: ApplicationInformation -> FilePath -> IO (Maybe Text)
- readApplicationSpecificConfigFile :: ApplicationInformation -> FilePath -> IO (Maybe Text)
- readApplicationSpecificDataFile :: ApplicationInformation -> FilePath -> IO (Maybe Text)
- writeApplicationSpecificCacheFile :: ApplicationInformation -> FilePath -> Text -> IO ()
- writeApplicationSpecificConfigFile :: ApplicationInformation -> FilePath -> Text -> IO ()
- writeApplicationSpecificDataFile :: ApplicationInformation -> FilePath -> Text -> IO ()
- listApplicationSpecificDataFiles :: ApplicationInformation -> IO [FilePath]
- clearApplicationSpecificCache :: ApplicationInformation -> IO FilePath
- touchApplicationSpecificRuntimeFile :: ApplicationInformation -> FilePath -> IO Bool
Record of information for your application:
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
— POSIX-Idiomatic naming convention (only alphanums and lowercase, seeasPosixDirectory
).$sel:windowsDirectory:ApplicationInformation
— Windows-Idiomatic naming convention (with spaces, plus the vendor name, seeasWindowsDirectory
).$sel:macintoshDirectory:ApplicationInformation
— MacOS-Idiomatic naming convention (with hyphens, plus the qualified vendor URI, seeasMacintoshDirectory
).
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
= "sboosali/My Application/"$sel:macintoshDirectory:ApplicationInformation
= "io.sboosali.My-Application/"
ApplicationInformation | |
|
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
defaultApplicationInformation0 :: ApplicationInformation0 Source #
Required fields are ""
. Optional fields are Nothing
.
asExecutableName :: String -> String Source #
Construct a $sel:executable:ApplicationInformation
from a $sel:name:ApplicationInformation
.
Examples
>>>
asExecutableName "My Application"
"my-application"
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
Enumeration of your application's supported platforms.
data DesktopPlatform Source #
Platform for desktop applications.
Instances
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/"
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/"
Application-specific, XDG-conformant filepaths:
XDG-conformant filepaths, specific to your application (ApplicationInformation
), and idiomatic for your platform (DesktopPlatform
).
$XDG_CONFIG_HOME
$XDG_DATA_HOME
$XDG_CACHE_HOME
$XDG_RUNTIME_HOME
Read application-specific files.
Write application-specific files.
writeApplicationSpecificCacheFile :: ApplicationInformation -> FilePath -> Text -> IO () Source #
writeApplicationSpecificConfigFile :: ApplicationInformation -> FilePath -> Text -> IO () Source #
writeApplicationSpecificDataFile :: ApplicationInformation -> FilePath -> Text -> IO () Source #
$XDG_CONFIG_HOME
utilities:
$XDG_DATA_HOME
utilities:
$XDG_CACHE_HOME
utilities:
$XDG_RUNTIME_HOME
utilities:
The getMyApplication{Config,Data,Cache}Directory
operations
return this application's (platform-specific, user-writeable) directory
for {configuration files, data files, caching}
.
The getMyApplication{Config,Data,Cache}Directory
operations may throw these exceptions (all IOError
s):
System.IO.HardwareFault
A physical I/O error has occurred.[EIO]
isDoesNotExistError
There is no path referring to the working directory.[EPERM, ENOENT, ESTALE...]
isPermissionError
The process has insufficient privileges to perform the operation.[EACCES]
isFullError
Insufficient resources are available to perform the operation.UnsupportedOperation
The operating system has no notion of current working directory.