cli

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2013 License: BSD-3-Clause, GPL-3.0, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CopyCommand = Command{
	Name:     "copy",
	Synopsis: "Create a copy of a tag",
	Description: `tmsu copy TAG NEW...

Creates a new tag NEW applied to the same set of files as TAG.

Examples:

    $ tmsu copy cheese wine
    $ tmsu copy report document`,
	Options: Options{},
	Exec:    copyExec,
}
View Source
var DeleteCommand = Command{
	Name:     "delete",
	Synopsis: "Delete one or more tags",
	Description: `tmsu delete TAG...

Permanently deletes the TAGs specified.

Examples:

    $ tmsu delete pineapple
    $ tmsu delete red green blue`,
	Options: Options{},
	Exec:    deleteExec,
}
View Source
var DupesCommand = Command{
	Name:     "dupes",
	Synopsis: "Identify duplicate files",
	Description: `tmsu dupes [FILE]...

Identifies all files in the database that are exact duplicates of FILE. If no
FILE is specified then identifies duplicates between files in the database.

Examples:

    $ tmsu dupes
    Set of 2 duplicates:
      /tmp/song.mp3
      /tmp/copy of song.mp3
    $ tmsu dupes /tmp/song.mp3
    /tmp/copy of song.mp3`,
	Options: Options{Option{"--recursive", "-r", "recursively check directory contents", false, ""}},
	Exec:    dupesExec,
}
View Source
var FilesCommand = Command{
	Name:     "files",
	Synopsis: "List files with particular tags",
	Description: `tmsu files [OPTION]... QUERY 

Lists the files that match the QUERY specified. QUERY may contain tag names,
logical operators ('not', 'and', 'or') and parentheses.

If multiple tags are specified without a logical operator between them this
will be interpretted as an implicit 'and', e.g. 'chalk cheese' is interpretted as
'chalk and cheese'.

Examples:

    $ tmsu files music mp3                 # files with both 'music' and 'mp3'
    /tmp/some jazz.mp3
    /tmp/some pop.mp3
    $ tmsu files music and mp3             # same query but with explicit 'and'
    /tmp/some jazz.mp3
    /tmp/some pop.mp3
    $ tmsu files music and not mp3
    /tmp/some classical.flac
    $ tmsu files "music and (mp3 or flac)"
    /tmp/some classical.flac
    /tmp/some jazz.mp3
    /tmp/some pop.mp3`,
	Options: Options{{"--all", "-a", "list the complete set of tagged files", false, ""},
		{"--directory", "-d", "list only items that are directories", false, ""},
		{"--file", "-f", "list only items that are files", false, ""},
		{"--top", "-t", "list only the top-most matching items (excludes the contents of matching directories)", false, ""},
		{"--leaf", "-l", "list only the leaf items (files and empty directories)", false, ""},
		{"--recursive", "-r", "read all files on the file-system under each matching directory, recursively", false, ""},
		{"--print0", "-0", "delimit files with a NUL character rather than newline.", false, ""},
		{"--count", "-c", "lists the number of files rather than their names", false, ""}},
	Exec: filesExec,
}
View Source
var HelpCommand = Command{
	Name:     "help",
	Synopsis: "List commands or show help for a particular command",
	Description: `tmsu help [OPTION]... [COMMAND]

Shows help summary or, where COMMAND is specified, help for COMMAND.`,
	Options: Options{{"--list", "-l", "list commands", false, ""}},
	Exec:    helpExec,
}
View Source
var ImplyCommand = Command{
	Name:     "imply",
	Synopsis: "Creates a tag implication",
	Description: `tmsu [OPTION] imply TAG IMPL...
tmsu imply --list

Creates a tag implication such that whenever TAG is applied, IMPL are automatically applied.

Examples:

    $ tmsu imply mp3 music
    $ tmsu imply --list
    mp3 ⇒ music
    $ tmsu imply --delete mp3 music`,
	Options: Options{Option{"--delete", "-d", "deletes the tag implication", false, ""},
		Option{"--list", "-l", "lists the tag implications", false, ""}},
	Exec: implyExec,
}
View Source
var MergeCommand = Command{
	Name:     "merge",
	Synopsis: "Merge tags",
	Description: `tmsu merge TAG... DEST
        
Merges TAGs into tag DEST resulting in a single tag of name DEST.

Examples:

    $ tmsu merge cehese cheese
    $ tmsu merge outdoors outdoor outside`,
	Options: Options{},
	Exec:    mergeExec,
}
View Source
var MountCommand = Command{
	Name:     "mount",
	Synopsis: "Mount the virtual filesystem",
	Description: `tmsu mount
tmsu mount [OPTION]... [FILE] MOUNTPOINT

Without arguments, lists the currently mounted file-systems, otherwise mounts a
virtual file-system at the path MOUNTPOINT.

Where FILE is specified, the database at FILE is mounted.

If FILE is not specified but the TMSU_DB environment variable is defined then
the database at TMSU_DB is mounted.

Where neither FILE is specified nor TMSU_DB defined then the default database
is mounted.

To allow other users access to the mounted filesystem, pass the 'allow_other'
FUSE option, e.g. 'tmsu mount --option=allow_other mp'. (FUSE only allows the
root user to use this option unless 'user_allow_other' is present in
'/etc/fuse.conf'.)

Examples:

    $ tmsu mount mp
    $ tmsu mount /tmp/db mp
    $ tmsu mount --options=allow_other mp`,
	Options: Options{Option{"--options", "-o", "mount options (passed to fusermount)", true, ""}},
	Exec:    mountExec,
}
View Source
var RenameCommand = Command{
	Name:     "rename",
	Synopsis: "Rename a tag",
	Description: `tmsu rename OLD NEW

Renames a tag from OLD to NEW.

Attempting to rename a tag with a new name for which a tag already exists will result in an error.
To merge tags use the 'merge' command instead.

Examples:

    $ tmsu rename montain mountain`,
	Options: Options{},
	Exec:    renameExec,
}
View Source
var RepairCommand = Command{
	Name:     "repair",
	Synopsis: "Repair the database",
	Description: `tmsu [OPTION]... repair [PATH]...

Fixes broken paths and stale fingerprints in the database caused by file
modifications and moves.

Where no PATHS are specified all files in the database are checked.

                                          Reported Repaired
    Modified files                          yes      yes
    Moved files                             yes      yes
    Missing files                           yes      no
    Untagged files                          yes      no

Modified files are identified by a change to the file's modification time or
file size. These files are repaired by updating the modification time, size and
fingerprint in the database.

Moved files will only be repaired if a file with the same fingerprint can be
found under PATHs: this means files that are simultaneously moved and modified
will not be identified. Where no PATHs are specified, moved files will only be
identified if moved to a tagged directory.

Missing files are reported but are not, by default, removed from the database
as this would destroy the tagging information associated with them. If you do
wish to clear missing files from the database and destroying the associated
tagging information then use the --force option.

Untagged files are reported but not added to the database.

Examples:

    $ tmsu repair
    $ tmsu repair .
    $ tmsu repair --force`,
	Options: Options{{"--pretend", "-p", "do not make any changes", false, ""},
		{"--force", "-f", "remove missing files from the database", false, ""}},
	Exec: repairExec,
}
View Source
var StatsCommand = Command{
	Name:     "stats",
	Synopsis: "Show database statistics",
	Description: `tmsu stats

Shows the database statistics.`,
	Options: Options{},
	Exec:    statsExec,
}
View Source
var StatusCommand = Command{
	Name:     "status",
	Synopsis: "List the file tagging status",
	Description: `tmsu status [PATH]...

Shows the status of PATHs.

Where PATHs are not specified the status of the database is shown.

  T - Tagged
  M - Modified
  ! - Missing
  U - Untagged

Status codes of T, M and ! mean that the file has been tagged (and thus is in
the TMSU database). Modified files are those with a different modification time
or size to that in the database. Missing files are those in the database but
that no longer exist in the file-system.

Note: The 'repair' command can be used to fix problems caused by files that have
been modified or moved on disk.

Examples:

    $ tmsu status
    $ tmsu status .
    $ tmsu status --directory *`,
	Options: Options{Option{"--directory", "-d", "list directory entries only: do not list contents", false, ""}},
	Exec:    statusExec,
}
View Source
var TagCommand = Command{
	Name:     "tag",
	Synopsis: "Apply tags to files",
	Description: `tmsu tag [OPTION]... FILE TAG...
tmsu tag [OPTION]... --tags="TAG..." FILE...
tmsu tag [OPTION]... --from=FILE FILE...
tmsu tag [OPTION]... --create TAG...

Tags the file FILE with the tag(s) specified.

Examples:

    $ tmsu tag mountain1.jpg photo landscape holiday good country:france
    $ tmsu tag --from=mountain1.jpg mountain2.jpg
    $ tmsu tag --tags="landscape" field1.jpg field2.jpg
    $ tmsu tag --create bad rubbish awful`,
	Options: Options{{"--tags", "-t", "the set of tags to apply", true, ""},
		{"--recursive", "-r", "recursively apply tags to directory contents", false, ""},
		{"--from", "-f", "copy tags from the specified file", true, ""},
		{"--create", "-c", "create a tag without tagging any files", false, ""}},
	Exec: tagExec,
}
View Source
var TagsCommand = Command{
	Name:     "tags",
	Synopsis: "List tags",
	Description: `tmsu tags [OPTION]... [FILE]...

Lists the tags applied to FILEs.

When run with no arguments, tags for the current working directory are listed.

Examples:

    $ tmsu tags
    tralala.mp3: mp3 music opera 
    $ tmsu tags tralala.mp3
    mp3
    music
    opera
    $ tmsu tags --count tralala.mp3
    3`,
	Options: Options{{"--all", "-a", "lists all of the tags defined", false, ""},
		{"--count", "-c", "lists the number of tags rather than their names", false, ""}},
	Exec: tagsExec,
}
View Source
var UnmountCommand = Command{
	Name:     "unmount",
	Synopsis: "Unmount the virtual filesystem",
	Description: `tmsu unmount MOUNTPOINT
tmsu unmount --all

Unmounts the virtual file-system at MOUNTPOINT.`,
	Options: Options{{"--all", "-a", "unmounts all mounted TMSU file-systems", false, ""}},
	Exec:    unmountExec,
}
View Source
var UntagCommand = Command{
	Name:     "untag",
	Synopsis: "Remove tags from files",
	Description: `tmsu untag [OPTION]... FILE TAG...
tmsu untag [OPTION]... --all FILE...
tmsu untag [OPTION]... --tags="TAG..." FILE...

Disassociates FILE with the TAGs specified.

Examples:

    $ tmsu untag mountain.jpg hill
    $ tmsu untag --all mountain-copy.jpg
    $ tmsu untag --tags="river underwater" forest.jpg desert.jpg`,
	Options: Options{{"--all", "-a", "strip each file of all tags", false, ""},
		{"--tags", "-t", "the set of tags to remove", true, ""},
		{"--recursive", "-r", "recursively remove tags from directory contents", false, ""}},
	Exec: untagExec,
}
View Source
var VersionCommand = Command{
	Name:     "version",
	Synopsis: "Display version and copyright information",
	Description: `tmsu version

Displays version and copyright information.`,
	Options: Options{},
	Exec:    versionExec,
}
View Source
var VfsCommand = Command{
	Name:     "vfs",
	Synopsis: "",
	Description: `This command is the foreground process which hosts the virtual filesystem.
It is run automatically when a virtual filesystem is mounted using the 'mount' command
and terminated when the virtual filesystem is unmounted.

It is not normally necessary to issue this command manually unless debugging the virtual
filesystem. For debug output use the --verbose option.`,
	Options: Options{{"--options", "-o", "mount options", true, ""}},
	Exec:    vfsExec,
}

Functions

func Run added in v0.3.0

func Run()

func ValidateTagName

func ValidateTagName(tagName string) error

func ValidateTagNames added in v0.3.0

func ValidateTagNames(tagNames []string) error

Types

type Command

type Command struct {
	Name        string
	Synopsis    string
	Description string
	Options     Options
	Exec        func(options Options, args []string) error
}

type Option

type Option struct {
	LongName    string
	ShortName   string
	Description string
	HasArgument bool
	Argument    string
}

type OptionParser added in v0.3.0

type OptionParser struct {
	// contains filtered or unexported fields
}

func NewOptionParser added in v0.3.0

func NewOptionParser(globalOptions Options, commandByName map[string]*Command) *OptionParser

func (*OptionParser) Parse added in v0.3.0

func (parser *OptionParser) Parse(args []string) (commandName string, options Options, arguments []string, err error)

type Options

type Options []Option

func (Options) Count added in v0.3.0

func (options Options) Count(name string) uint

func (Options) Get

func (options Options) Get(name string) *Option

func (Options) HasOption

func (options Options) HasOption(name string) bool

type Row added in v0.3.0

type Row struct {
	Path   string
	Status Status
}

type Status added in v0.3.0

type Status byte
const (
	UNTAGGED Status = 'U'
	TAGGED   Status = 'T'
	MODIFIED Status = 'M'
	MISSING  Status = '!'
)

type StatusReport added in v0.3.0

type StatusReport struct {
	Rows []Row
}

func NewReport added in v0.3.0

func NewReport() *StatusReport

func (*StatusReport) AddRow added in v0.3.0

func (report *StatusReport) AddRow(row Row)

func (*StatusReport) ContainsRow added in v0.3.0

func (report *StatusReport) ContainsRow(path string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL