@@ -3,6 +3,7 @@
3module Obelisk.Command where
3module Obelisk.Command where
5import Control.Monad
5import Control.Monad
6import Data.Monoid
7import Data.Monoid
7import Options.Applicative
8import Options.Applicative
8import System.Environment
9import System.Environment
@@ -114,14 +115,18 @@ main = do
114 --TODO: Use a proper logging system with log levels and whatnot
115 --TODO: Use a proper logging system with log levels and whatnot
115 True -> hPutStrLn stderr "NOTICE: --no-handoff should only be passed once and as the first argument; ignoring"
116 True -> hPutStrLn stderr "NOTICE: --no-handoff should only be passed once and as the first argument; ignoring"
118− "--no-handoff" : as -> go as -- If we've been told not to hand off, don't hand off
120− findProjectObeliskCommand "." >>= \case
118+ handoffAndGo as = findProjectObeliskCommand "." >>= \case
121− Nothing -> go as -- If we aren't in a project, just run ourselves
119+ Nothing -> go as -- If not in a project, just run ourselves
122 Just impl -> do
120 Just impl -> do
123 -- Invoke the real implementation, using --no-handoff to prevent infinite recursion
121 -- Invoke the real implementation, using --no-handoff to prevent infinite recursion
124 executeFile impl False ("--no-handoff" : myArgs) Nothing
122 executeFile impl False ("--no-handoff" : myArgs) Nothing
124+ "--no-handoff" : as -> go as -- If we've been told not to hand off, don't hand off
125+ a:as -- Otherwise bash completion would always hand-off even if the user isn't trying to
126+ | "--bash-completion" `isPrefixOf` a
127+ && "--no-handoff" `elem` as -> go (a:as)
128+ | otherwise -> handoffAndGo (a:as)
129+ as -> handoffAndGo as
126ob :: ObCommand -> IO ()
131ob :: ObCommand -> IO ()
127ob = \case
132ob = \case