Improve distro code

This commit is contained in:
Julian Ospald 2023-10-22 00:04:04 +08:00
parent f9a2b21cb0
commit 0adb602a96
No known key found for this signature in database
GPG Key ID: 4275CDA6A29BED43
3 changed files with 993 additions and 1061 deletions

View File

@ -209,19 +209,7 @@ platformParser s' = case MP.parse (platformP <* MP.eof) "" (T.pack s') of
)
]
distroP :: MP.Parsec Void Text LinuxDistro
distroP = choice'
[ MP.chunk "debian" $> Debian
, MP.chunk "deb" $> Debian
, MP.chunk "ubuntu" $> Ubuntu
, MP.chunk "mint" $> Mint
, MP.chunk "fedora" $> Fedora
, MP.chunk "centos" $> CentOS
, MP.chunk "redhat" $> RedHat
, MP.chunk "alpine" $> Alpine
, MP.chunk "gentoo" $> Gentoo
, MP.chunk "exherbo" $> Exherbo
, MP.chunk "unknown" $> UnknownLinux
]
distroP = choice' ((\d -> MP.chunk (T.pack $ distroToString d) $> d) <$> allDistros)
uriParser :: String -> Either String URI
@ -367,7 +355,7 @@ fileUri' add = \case
-- We need to do this so bash doesn't expand out any ~ or other
-- chars we want to complete on, or emit an end of line error
-- when seeking the close to the quote.
--
--
-- NOTE: copied from https://hackage.haskell.org/package/optparse-applicative-0.17.0.0/docs/src/Options.Applicative.Builder.Completer.html#requote
requote :: String -> String
requote s =

View File

@ -249,15 +249,18 @@ data LinuxDistro = Debian
| RedHat
| Alpine
| AmazonLinux
| RockyLinux
| VoidLinux
| Rocky
| Void
-- rolling
| Gentoo
| Exherbo
-- not known
| UnknownLinux
-- ^ must exit
deriving (Eq, GHC.Generic, Ord, Show)
deriving (Eq, GHC.Generic, Ord, Show, Enum, Bounded)
allDistros :: [LinuxDistro]
allDistros = enumFromTo minBound maxBound
instance NFData LinuxDistro
@ -270,8 +273,8 @@ distroToString CentOS = "centos"
distroToString RedHat = "redhat"
distroToString Alpine = "alpine"
distroToString AmazonLinux = "amazon"
distroToString RockyLinux = "rocky"
distroToString VoidLinux = "void"
distroToString Rocky = "rocky"
distroToString Void = "void"
distroToString Gentoo = "gentoo"
distroToString Exherbo = "exherbo"
distroToString UnknownLinux = "unknown"

File diff suppressed because it is too large Load Diff