-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6548 from phadej/man-command
Change manpage command to man
- Loading branch information
Showing
13 changed files
with
110 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
module Distribution.Client.ManpageFlags | ||
( ManpageFlags (..) | ||
, defaultManpageFlags | ||
, manpageOptions, | ||
) where | ||
|
||
import Distribution.Client.Compat.Prelude | ||
|
||
import Distribution.Simple.Command (OptionField (..), ShowOrParseArgs (..), option) | ||
import Distribution.Simple.Setup (Flag (..), toFlag, trueArg, optionVerbosity) | ||
import Distribution.Verbosity (Verbosity, normal) | ||
|
||
data ManpageFlags = ManpageFlags | ||
{ manpageVerbosity :: Flag Verbosity | ||
, manpageRaw :: Flag Bool | ||
} deriving (Eq, Show, Generic) | ||
|
||
instance Monoid ManpageFlags where | ||
mempty = gmempty | ||
mappend = (<>) | ||
|
||
instance Semigroup ManpageFlags where | ||
(<>) = gmappend | ||
|
||
defaultManpageFlags :: ManpageFlags | ||
defaultManpageFlags = ManpageFlags | ||
{ manpageVerbosity = toFlag normal | ||
, manpageRaw = toFlag False | ||
} | ||
|
||
manpageOptions :: ShowOrParseArgs -> [OptionField ManpageFlags] | ||
manpageOptions _ = | ||
[ optionVerbosity manpageVerbosity (\v flags -> flags { manpageVerbosity = v }) | ||
, option "" ["raw"] | ||
"Output raw troff content" | ||
manpageRaw (\v flags -> flags { manpageRaw = v }) | ||
trueArg | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,3 @@ | ||
import Distribution.PackageDescription ( PackageDescription ) | ||
import Distribution.Simple ( defaultMainWithHooks | ||
, simpleUserHooks | ||
, postBuild | ||
, postCopy | ||
, postInst | ||
) | ||
import Distribution.Simple.InstallDirs ( mandir | ||
, CopyDest (NoCopyDest) | ||
) | ||
import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..) | ||
, absoluteInstallDirs | ||
) | ||
import Distribution.Simple.Utils ( installOrdinaryFiles | ||
, notice ) | ||
import Distribution.Simple.Setup ( buildVerbosity | ||
, copyDest | ||
, copyVerbosity | ||
, fromFlag | ||
, installVerbosity | ||
) | ||
import Distribution.Verbosity ( Verbosity ) | ||
|
||
import System.IO ( openFile | ||
, IOMode (WriteMode) | ||
) | ||
import System.Process ( runProcess ) | ||
import System.FilePath ( (</>) ) | ||
|
||
-- WARNING to editors of this file: | ||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
-- At this moment (Cabal 1.23), whatever you write here must be | ||
-- compatible with ALL Cabal libraries which we support bootstrapping | ||
-- with. This is because pre-setup-depends versions of cabal-install will | ||
-- build Setup.hs against the version of Cabal which MATCHES the library | ||
-- that cabal-install was built against. There is no way of overriding | ||
-- this behavior without bumping the required 'cabal-version' in our | ||
-- Cabal file. Travis will let you know if we fail to install from | ||
-- tarball! | ||
|
||
import Distribution.Simple | ||
main :: IO () | ||
main = defaultMainWithHooks $ simpleUserHooks | ||
{ postBuild = \ _ flags _ lbi -> | ||
buildManpage lbi (fromFlag $ buildVerbosity flags) | ||
, postCopy = \ _ flags pkg lbi -> | ||
installManpage pkg lbi (fromFlag $ copyVerbosity flags) (fromFlag $ copyDest flags) | ||
, postInst = \ _ flags pkg lbi -> | ||
installManpage pkg lbi (fromFlag $ installVerbosity flags) NoCopyDest | ||
} | ||
|
||
buildManpage :: LocalBuildInfo -> Verbosity -> IO () | ||
buildManpage lbi verbosity = do | ||
let cabal = buildDir lbi </> "cabal/cabal" | ||
manpage = buildDir lbi </> "cabal/cabal.1" | ||
manpageHandle <- openFile manpage WriteMode | ||
notice verbosity ("Generating manual page " ++ manpage ++ " ...") | ||
_ <- runProcess cabal ["manpage"] Nothing Nothing Nothing (Just manpageHandle) Nothing | ||
return () | ||
|
||
installManpage :: PackageDescription -> LocalBuildInfo -> Verbosity -> CopyDest -> IO () | ||
installManpage pkg lbi verbosity copy = do | ||
let destDir = mandir (absoluteInstallDirs pkg lbi copy) </> "man1" | ||
installOrdinaryFiles verbosity destDir [(buildDir lbi </> "cabal", "cabal.1")] | ||
main = defaultMain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# cabal manpage | ||
# cabal man |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import Test.Cabal.Prelude | ||
main = cabalTest $ do | ||
r <- cabal' "manpage" [] | ||
r <- cabal' "man" ["--raw"] | ||
assertOutputContains ".B cabal install" r | ||
assertOutputDoesNotContain ".B cabal manpage" r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters