more descriptive name for oneshot
This commit is contained in:
parent
9a9b4b840e
commit
ba0334116c
13 changed files with 20 additions and 19 deletions
|
@ -298,9 +298,9 @@ getKeysPresent = liftIO . traverse (2 :: Int) =<< fromRepo gitAnnexObjectDir
|
||||||
- especially if performing a short-lived action.
|
- especially if performing a short-lived action.
|
||||||
-}
|
-}
|
||||||
saveState :: Bool -> Annex ()
|
saveState :: Bool -> Annex ()
|
||||||
saveState oneshot = doSideAction $ do
|
saveState nocommit = doSideAction $ do
|
||||||
Annex.Queue.flush
|
Annex.Queue.flush
|
||||||
unless oneshot $
|
unless nocommit $
|
||||||
whenM alwayscommit $
|
whenM alwayscommit $
|
||||||
Annex.Branch.commit "update"
|
Annex.Branch.commit "update"
|
||||||
where
|
where
|
||||||
|
|
|
@ -43,7 +43,7 @@ dispatch fuzzyok allargs allcmds commonoptions fields header getgitrepo = do
|
||||||
forM_ fields $ \(f, v) -> Annex.setField f v
|
forM_ fields $ \(f, v) -> Annex.setField f v
|
||||||
sequence_ flags
|
sequence_ flags
|
||||||
prepCommand cmd params
|
prepCommand cmd params
|
||||||
tryRun state' cmd $ [startup] ++ actions ++ [shutdown $ cmdoneshot cmd]
|
tryRun state' cmd $ [startup] ++ actions ++ [shutdown $ cmdnocommit cmd]
|
||||||
where
|
where
|
||||||
err msg = msg ++ "\n\n" ++ usage header allcmds commonoptions
|
err msg = msg ++ "\n\n" ++ usage header allcmds commonoptions
|
||||||
cmd = Prelude.head cmds
|
cmd = Prelude.head cmds
|
||||||
|
@ -112,8 +112,8 @@ startup = return True
|
||||||
|
|
||||||
{- Cleanup actions. -}
|
{- Cleanup actions. -}
|
||||||
shutdown :: Bool -> Annex Bool
|
shutdown :: Bool -> Annex Bool
|
||||||
shutdown oneshot = do
|
shutdown nocommit = do
|
||||||
saveState oneshot
|
saveState nocommit
|
||||||
sequence_ =<< M.elems <$> Annex.getState Annex.cleanup
|
sequence_ =<< M.elems <$> Annex.getState Annex.cleanup
|
||||||
liftIO Git.Command.reap -- zombies from long-running git processes
|
liftIO Git.Command.reap -- zombies from long-running git processes
|
||||||
sshCleanup -- ssh connection caching
|
sshCleanup -- ssh connection caching
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
module Command (
|
module Command (
|
||||||
command,
|
command,
|
||||||
noRepo,
|
noRepo,
|
||||||
oneShot,
|
noCommit,
|
||||||
withOptions,
|
withOptions,
|
||||||
next,
|
next,
|
||||||
stop,
|
stop,
|
||||||
|
@ -43,9 +43,10 @@ import Annex.CheckAttr
|
||||||
command :: String -> String -> [CommandSeek] -> String -> Command
|
command :: String -> String -> [CommandSeek] -> String -> Command
|
||||||
command = Command [] Nothing commonChecks False
|
command = Command [] Nothing commonChecks False
|
||||||
|
|
||||||
{- Makes a command run in oneshot mode. -}
|
{- Indicates that a command doesn't need to commit any changes to
|
||||||
oneShot :: Command -> Command
|
- the git-annex branch. -}
|
||||||
oneShot c = c { cmdoneshot = True }
|
noCommit :: Command -> Command
|
||||||
|
noCommit c = c { cmdnocommit = True }
|
||||||
|
|
||||||
{- Adds a fallback action to a command, that will be run if it's used
|
{- Adds a fallback action to a command, that will be run if it's used
|
||||||
- outside a git repository. -}
|
- outside a git repository. -}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import Command
|
||||||
import Annex.UUID
|
import Annex.UUID
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [oneShot $ command "configlist" paramNothing seek
|
def = [noCommit $ command "configlist" paramNothing seek
|
||||||
"outputs relevant git configuration"]
|
"outputs relevant git configuration"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
|
|
|
@ -15,7 +15,7 @@ import Annex.Content
|
||||||
import Types.Key
|
import Types.Key
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [oneShot $ command "dropkey" (paramRepeating paramKey) seek
|
def = [noCommit $ command "dropkey" (paramRepeating paramKey) seek
|
||||||
"drops annexed content for specified keys"]
|
"drops annexed content for specified keys"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
|
|
|
@ -12,7 +12,7 @@ import Command
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [oneShot $ command "inannex" (paramRepeating paramKey) seek
|
def = [noCommit $ command "inannex" (paramRepeating paramKey) seek
|
||||||
"checks if keys are present in the annex"]
|
"checks if keys are present in the annex"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
|
|
|
@ -16,7 +16,7 @@ import Logs.Transfer
|
||||||
import Command.SendKey (fieldTransfer)
|
import Command.SendKey (fieldTransfer)
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [oneShot $ command "recvkey" paramKey seek
|
def = [noCommit $ command "recvkey" paramKey seek
|
||||||
"runs rsync in server mode to receive content"]
|
"runs rsync in server mode to receive content"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
|
|
|
@ -15,7 +15,7 @@ import Logs.Transfer
|
||||||
import qualified Fields
|
import qualified Fields
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [oneShot $ command "sendkey" paramKey seek
|
def = [noCommit $ command "sendkey" paramKey seek
|
||||||
"runs rsync in server mode to send content"]
|
"runs rsync in server mode to send content"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
|
|
|
@ -19,7 +19,7 @@ import qualified Option
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [withOptions options $
|
def = [withOptions options $
|
||||||
oneShot $ command "transferkey" paramKey seek
|
noCommit $ command "transferkey" paramKey seek
|
||||||
"transfers a key from or to a remote"]
|
"transfers a key from or to a remote"]
|
||||||
|
|
||||||
options :: [Option]
|
options :: [Option]
|
||||||
|
|
|
@ -13,7 +13,7 @@ import qualified Build.SysConfig as SysConfig
|
||||||
import Annex.Version
|
import Annex.Version
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [oneShot $ noRepo showPackageVersion $ dontCheck repoExists $
|
def = [noCommit $ noRepo showPackageVersion $ dontCheck repoExists $
|
||||||
command "version" paramNothing seek "show version info"]
|
command "version" paramNothing seek "show version info"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
|
|
|
@ -31,7 +31,7 @@ import Control.Concurrent
|
||||||
import Control.Concurrent.STM
|
import Control.Concurrent.STM
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [oneShot $ noRepo startNoRepo $ dontCheck repoExists $
|
def = [noCommit $ noRepo startNoRepo $ dontCheck repoExists $
|
||||||
command "webapp" paramNothing seek "launch webapp"]
|
command "webapp" paramNothing seek "launch webapp"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
|
|
|
@ -15,7 +15,7 @@ import Remote
|
||||||
import Logs.Trust
|
import Logs.Trust
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [command "whereis" paramPaths seek
|
def = [noCommit $ command "whereis" paramPaths seek
|
||||||
"lists repositories that have file content"]
|
"lists repositories that have file content"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
|
|
|
@ -38,7 +38,7 @@ data Command = Command
|
||||||
{ cmdoptions :: [Option] -- command-specific options
|
{ cmdoptions :: [Option] -- command-specific options
|
||||||
, cmdnorepo :: Maybe (IO ()) -- an action to run when not in a repo
|
, cmdnorepo :: Maybe (IO ()) -- an action to run when not in a repo
|
||||||
, cmdcheck :: [CommandCheck] -- check stage
|
, cmdcheck :: [CommandCheck] -- check stage
|
||||||
, cmdoneshot :: Bool -- don't save state after running
|
, cmdnocommit :: Bool -- don't commit journalled state changes
|
||||||
, cmdname :: String
|
, cmdname :: String
|
||||||
, cmdparamdesc :: String -- description of params for usage
|
, cmdparamdesc :: String -- description of params for usage
|
||||||
, cmdseek :: [CommandSeek] -- seek stage
|
, cmdseek :: [CommandSeek] -- seek stage
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue