2014-02-19 00:01:56 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2014 Joey Hess <id@joeyh.name>
|
2014-02-19 00:01:56 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.VAdd where
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import Annex.View
|
2014-03-02 18:53:19 +00:00
|
|
|
import Command.View (checkoutViewBranch)
|
2014-02-19 00:01:56 +00:00
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
2015-07-08 19:08:02 +00:00
|
|
|
cmd = notBareRepo $ notDirect $
|
|
|
|
command "vadd" SectionMetaData
|
|
|
|
"add subdirs to current view"
|
|
|
|
(paramRepeating "FIELD=GLOB")
|
|
|
|
(withParams seek)
|
2014-02-19 00:01:56 +00:00
|
|
|
|
2015-07-08 19:08:02 +00:00
|
|
|
seek :: CmdParams -> CommandSeek
|
2018-10-01 18:12:06 +00:00
|
|
|
seek = withWords (commandAction . start)
|
2014-02-19 00:01:56 +00:00
|
|
|
|
|
|
|
start :: [String] -> CommandStart
|
|
|
|
start params = do
|
2017-11-28 18:40:26 +00:00
|
|
|
showStart' "vadd" Nothing
|
add tip about metadata driven views (and more flexible view filtering)
While writing this documentation, I realized that there needed to be a way
to stay in a view like tag=* while adding a filter like tag=work that
applies to the same field.
So, there are really two ways a view can be refined. It can have a new
"field=explicitvalue" filter added to it, which does not change the
"shape" of the view, but narrows the files it shows.
Or, it can have a new view added, which adds another level of
subdirectories.
So, added a vfilter command, which takes explicit values to add to the
filter, and rejects changes that would change the shape of the view.
And, made vadd only accept changes that change the shape of the view.
And, changed the View data type slightly; now components that can match
multiple metadata values can be visible, or not visible.
This commit was sponsored by Stelian Iancu.
2014-02-19 19:10:18 +00:00
|
|
|
withCurrentView $ \view -> do
|
|
|
|
let (view', change) = refineView view $
|
|
|
|
map parseViewParam $ reverse params
|
2014-02-19 00:01:56 +00:00
|
|
|
case change of
|
|
|
|
Unchanged -> do
|
|
|
|
showNote "unchanged"
|
|
|
|
next $ next $ return True
|
add tip about metadata driven views (and more flexible view filtering)
While writing this documentation, I realized that there needed to be a way
to stay in a view like tag=* while adding a filter like tag=work that
applies to the same field.
So, there are really two ways a view can be refined. It can have a new
"field=explicitvalue" filter added to it, which does not change the
"shape" of the view, but narrows the files it shows.
Or, it can have a new view added, which adds another level of
subdirectories.
So, added a vfilter command, which takes explicit values to add to the
filter, and rejects changes that would change the shape of the view.
And, made vadd only accept changes that change the shape of the view.
And, changed the View data type slightly; now components that can match
multiple metadata values can be visible, or not visible.
This commit was sponsored by Stelian Iancu.
2014-02-19 19:10:18 +00:00
|
|
|
Narrowing -> next $ next $ do
|
|
|
|
if visibleViewSize view' == visibleViewSize view
|
2016-11-16 01:29:54 +00:00
|
|
|
then giveup "That would not add an additional level of directory structure to the view. To filter the view, use vfilter instead of vadd."
|
add tip about metadata driven views (and more flexible view filtering)
While writing this documentation, I realized that there needed to be a way
to stay in a view like tag=* while adding a filter like tag=work that
applies to the same field.
So, there are really two ways a view can be refined. It can have a new
"field=explicitvalue" filter added to it, which does not change the
"shape" of the view, but narrows the files it shows.
Or, it can have a new view added, which adds another level of
subdirectories.
So, added a vfilter command, which takes explicit values to add to the
filter, and rejects changes that would change the shape of the view.
And, made vadd only accept changes that change the shape of the view.
And, changed the View data type slightly; now components that can match
multiple metadata values can be visible, or not visible.
This commit was sponsored by Stelian Iancu.
2014-02-19 19:10:18 +00:00
|
|
|
else checkoutViewBranch view' narrowView
|
2016-11-16 01:29:54 +00:00
|
|
|
Widening -> giveup "Widening view to match more files is not currently supported."
|