cli

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2019 License: BSD-3-Clause, GPL-3.0, MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigCommand = Command{
	Name:     "config",
	Synopsis: "Views or amends database settings",
	Usages: []string{"tmsu config",
		"tmsu config NAME[=VALUE]..."},
	Description: `Lists or views the database settings for the current database.

Without arguments the complete set of settings are shown, otherwise lists the settings for the specified setting NAMEs.

If a VALUE is specified then the setting is updated.`,
	Options: Options{},
	Exec:    configExec,
}
View Source
var CopyCommand = Command{
	Name:        "copy",
	Aliases:     []string{"cp"},
	Synopsis:    "Create a copy of a tag",
	Usages:      []string{"tmsu copy TAG NEW..."},
	Description: `Creates a new tag NEW applied to the same set of files as TAG.`,
	Examples: []string{"$ tmsu copy cheese wine",
		"$ tmsu copy report document text"},
	Options: Options{},
	Exec:    copyExec,
}
View Source
var DeleteCommand = Command{
	Name:        "delete",
	Aliases:     []string{"del", "rm"},
	Synopsis:    "Delete one or more tags",
	Usages:      []string{"tmsu delete TAG..."},
	Description: `Permanently deletes the TAGs specified.`,
	Examples: []string{"$ tmsu delete pineapple",
		"$ tmsu delete red green blue"},
	Options: Options{Option{"--value", "", "delete a value", false, ""}},
	Exec:    deleteExec,
}
View Source
var DupesCommand = Command{
	Name:        "dupes",
	Synopsis:    "Identify duplicate files",
	Usages:      []string{"tmsu dupes [FILE]..."},
	Description: `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: []string{"$ tmsu dupes\nSet of 2 duplicates:\n  /tmp/song.mp3\n  /tmp/copy of song.mp3a",
		"$ tmsu dupes /tmp/song.mp3\n/tmp/copy of song.mp3"},
	Options: Options{Option{"--recursive", "-r", "recursively check directory contents", false, ""}},
	Exec:    dupesExec,
}
View Source
var FilesCommand = Command{
	Name:     "files",
	Aliases:  []string{"query"},
	Synopsis: "List files with particular tags",
	Usages:   []string{"tmsu files [OPTION]... [QUERY]"},
	Description: `Lists the files in the database that match the QUERY specified. If no query is specified, all files in the database are listed.

QUERY may contain tag names to match, operators and parentheses. Operators are: and or not == != < > <= >= eq ne lt gt le ge.

Queries are run against the database so the results may not reflect the current state of the filesystem. Only tagged files are matched: to identify untagged files use the 'untagged' subcommand.

Note: If your tag or value name contains whitespace, operators (e.g. '<') or parentheses ('(' or ')'), these must be escaped with a backslash '\', e.g. '\<tag\>' matches the tag name '<tag>'. Your shell, however, may use some punctuation for its own purposes: this can normally be avoided by enclosing the query in single quotation marks or by escaping the problem characters with a backslash.`,
	Examples: []string{"$ tmsu files music mp3  # files with both 'music' and 'mp3'",
		"$ tmsu files music and mp3  # same query but with explicit 'and'",
		"$ tmsu files music and not mp3",
		`$ tmsu files "music and (mp3 or flac)"`,
		`$ tmsu files "year == 2017"`,
		`$ tmsu files "year < 2017"`,
		`$ tmsu files year lt 2017`,
		`$ tmsu files year`,
		`$ tmsu files --path=/home/bob music`,
		`$ tmsu files 'contains\=equals'`,
		`$ tmsu files '\<tag\>'`},
	Options: Options{{"--directory", "-d", "list only items that are directories", false, ""},
		{"--file", "-f", "list only items that are files", 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, ""},
		{"--path", "-p", "list only items under PATH", true, ""},
		{"--explicit", "-e", "list only explicitly tagged files", false, ""},
		{"--sort", "-s", "sort output: id, none, name, size, time", true, ""},
		{"--ignore-case", "-i", "ignore the case of tag and value names", false, ""}},
	Exec: filesExec,
}
View Source
var HelpCommand = Command{
	Name:        "help",
	Synopsis:    "List subcommands or show help for a particular subcommand",
	Usages:      []string{"tmsu help [OPTION]... [SUBCOMMAND]"},
	Description: `Shows help summary or, where SUBCOMMAND is specified, help for SUBCOMMAND.`,
	Options:     Options{{"--list", "-l", "list commands", false, ""}},
	Exec:        helpExec,
}
View Source
var ImplyCommand = Command{
	Name:     "imply",
	Synopsis: "Creates a tag implication",
	Usages: []string{"tmsu imply [OPTION] TAG[=VALUE] IMPL[=VALUE]...",
		"tmsu imply"},
	Description: `Creates a tag implication such that any file tagged TAG will be implicitly tagged IMPL.

When run without arguments lists the set of tag implications.

Tag implications are applied at time of file query (not at time of tag application) therefore any changes to the implication rules will affect all further queries.

By default the 'tag' subcommand will not explicitly apply tags that are already implied by the implication rules.

The 'tags' subcommand can be used to identify which tags applied to a file are implied.`,
	Examples: []string{`$ tmsu imply mp3 music`,
		`$ tmsu imply
mp3 -> music`,
		`$ tmsu imply aubergine aka=eggplant`,
		`$ tmsu imply --delete mp3 music`},
	Options: Options{Option{"--delete", "-d", "deletes the tag implication", false, ""}},
	Exec:    implyExec,
}
View Source
var InfoCommand = Command{
	Name:        "info",
	Synopsis:    "Show database information",
	Usages:      []string{"tmsu info"},
	Description: "Shows the database information.",
	Options: Options{
		Option{"--stats", "-s", "show statistics", false, ""},
		Option{"--usage", "-u", "show tag usage breakdown", false, ""}},
	Exec:    infoExec,
	Aliases: []string{"stats"},
}
View Source
var InitCommand = Command{
	Name:     "init",
	Synopsis: "Initializes a new database",
	Usages:   []string{"tmsu init [PATH]"},
	Description: `Initializes a new local database.

Creates a .tmsu directory under PATH and initialises a new empty database within it.

If no PATH is specified then the current working directory is assumed.

The new database is used automatically whenever TMSU is invoked from a directory under PATH (unless overridden by the global --database option or the TMSU_DB environment variable.`,
	Options: Options{},
	Exec:    initExec,
}
View Source
var MergeCommand = Command{
	Name:        "merge",
	Synopsis:    "Merge tags",
	Usages:      []string{"tmsu merge TAG... DEST"},
	Description: `Merges TAGs into tag DEST resulting in a single tag of name DEST.`,
	Examples: []string{`$ tmsu merge cehese cheese`,
		`$ tmsu merge outdoors outdoor outside`},
	Options: Options{Option{"--value", "", "merge values", false, ""}},
	Exec:    mergeExec,
}
View Source
var MountCommand = Command{
	Name:     "mount",
	Synopsis: "Mount the virtual filesystem",
	Usages: []string{"tmsu mount",
		"tmsu mount [OPTION]... [FILE] MOUNTPOINT"},
	Description: `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 --options=allow_other mp'. (FUSE only allows the root user to use this option unless 'user_allow_other' is present in '/etc/fuse.conf'.)`,
	Examples: []string{"$ 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",
	Aliases:  []string{"mv"},
	Synopsis: "Rename a tag or value",
	Usages:   []string{"tmsu rename [OPTION]... OLD NEW"},
	Description: `Renames a tag or value from OLD to NEW.

Attempting to rename a tag or value with a name that already exists will result in an error. To merge tags or values use the 'merge' subcommand instead.`,
	Examples: []string{"$ tmsu rename montain mountain",
		"$ tmsu rename --value MMXVII 2017"},
	Options: Options{{"--value", "", "rename a value", false, ""}},
	Exec:    renameExec,
}
View Source
var RepairCommand = Command{
	Name:     "repair",
	Aliases:  []string{"fix"},
	Synopsis: "Repair the database",
	Usages: []string{"tmsu repair [OPTION]... [PATH]...",
		"tmsu repair [OPTION]... repair --manual OLD NEW"},
	Description: `Fixes broken paths and stale fingerprints in the database caused by file modifications and moves.

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

An attempt is made to find missing files under PATHs specified. If a file with the same fingerprint is found then the database is updated with the new file's details. If no PATHs are specified, or no match can be found, then the file is instead reported as missing.

Files that have been both moved and modified cannot be repaired and must be manually relocated.

When run with the --manual option, any paths that begin with OLD are updated to begin with NEW. Any affected files' fingerprints are updated providing the file exists at the new location. No further repairs are attempted in this mode.`,
	Examples: []string{"$ tmsu repair",
		"$ tmsu repair /new/path  # look for missing files here",
		"$ tmsu repair --path=/home/sally  # repair subset of database",
		"$ tmsu repair --manual /home/bob /home/fred  # manually repair paths"},
	Options: Options{{"--path", "-p", "limit repair to files in database under path", true, ""},
		{"--pretend", "-P", "do not make any changes", false, ""},
		{"--remove", "-R", "remove missing files from the database", false, ""},
		{"--manual", "-m", "manually relocate files", false, ""},
		{"--unmodified", "-u", "recalculate fingerprints for unmodified files", false, ""},
		{"--rationalize", "", "remove explicit taggings where an implicit tagging exists", false, ""}},
	Exec: repairExec,
}
View Source
var StatusCommand = Command{
	Name:     "status",
	Synopsis: "List the file tagging status",
	Usages:   []string{"tmsu status [PATH]..."},
	Description: `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' subcommand can be used to fix problems caused by files that have been modified or moved on disk.`,
	Examples: []string{"$ tmsu status",
		"$ tmsu status .",
		"$ tmsu status --directory *"},
	Options: Options{Option{"--directory", "-d", "do not examine directory contents (non-recursive)", false, ""},
		Option{"--no-dereference", "-P", "do not follow symbolic links", false, ""}},
	Exec: statusExec,
}
View Source
var TagCommand = Command{
	Name:     "tag",
	Synopsis: "Apply tags to files",
	Usages: []string{"tmsu tag [OPTION]... FILE TAG[=VALUE]...",
		`tmsu tag [OPTION]... --tags="TAG[=VALUE]..." FILE...`,
		"tmsu tag [OPTION]... --from=SOURCE FILE...",
		"tmsu tag [OPTION]... --where=QUERY TAG[=VALUE]...",
		"tmsu tag [OPTION]... --create {TAG|=VALUE}...",
		"tmsu tag [OPTION[... -"},
	Description: `Tags the file FILE with the TAGs and VALUEs specified.

Optionally tags applied to files may be attributed with a VALUE using the TAG=VALUE syntax.

Tag and value names may consist of one or more letter, number, punctuation and symbol characters (from the corresponding Unicode categories). Tag names cannot contain the slash '/' or backslash '\' characters.

Tags will not be applied if they are already implied by tag implications. This behaviour can be overridden with the --explicit option. See the 'imply' subcommand for more information.

If a single argument of - is passed, TMSU will read lines from standard input in the format 'FILE TAG[=VALUE]...'.

Note: The equals '=' and whitespace characters must be escaped with a backslash '\' when used within a tag or value name. However, your shell may use the backslash for its own purposes: this can normally be avoided by enclosing the argument in single quotation marks or by escaping the backslash with an additional backslash '\\'.`,
	Examples: []string{"$ 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 =2017",
		`$ tmsu tag --where="bad and good" confused`,
		"$ tmsu tag sheep.jpg '<tag>'"},
	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 SOURCE file", true, ""},
		{"--where", "-w", "tags files matching QUERY", true, ""},
		{"--create", "-c", "create tags or values without tagging any files", false, ""},
		{"--explicit", "-e", "explicitly apply tags even if they are already implied", false, ""},
		{"--force", "-F", "apply tags to non-existent or non-permissioned paths", false, ""},
		{"--no-dereference", "-P", "do not follow symbolic links (tag the link itself)", false, ""}},
	Exec: tagExec,
}
View Source
var TagsCommand = Command{
	Name:     "tags",
	Synopsis: "List tags",
	Usages:   []string{"tmsu tags [OPTION]... [FILE]..."},
	Description: `Lists the tags applied to FILEs. If no FILE is specified then all tags in the database are listed.

When color is turned on, tags are shown in the following colors:

  Normal  An explicitly applied (regular) tag
  'Cyan'    Tag implied by other tags
  'Yellow'  Tag is both explicitly applied and implied by other tags

See the 'imply' subcommand for more information on implied tags.`,
	Examples: []string{"$ tmsu tags\nmp3  music  opera",
		"$ tmsu tags tralala.mp3\nmp3  music  opera",
		"$ tmsu tags tralala.mp3 boom.mp3\n./tralala.mp3: mp3 music opera\n./boom.mp3: mp3 music drum-n-bass",
		"$ tmsu tags --count tralala.mp3",
		"$ tmsu tags --value 2009 red"},
	Options: Options{{"--count", "-c", "lists the number of tags rather than their names", false, ""},
		{"", "-1", "list one tag per line", false, ""},
		{"--explicit", "-e", "do not show implied tags", false, ""},
		{"--name", "-n", "when to print the file/value name: auto, always, never", true, ""},
		{"--no-dereference", "-P", "do not follow symlinks (show tags for symlink itself)", false, ""},
		{"--value", "-u", "show tags which utilise values", false, ""}},
	Exec: tagsExec,
}
View Source
var UnmountCommand = Command{
	Name:     "unmount",
	Aliases:  []string{"umount"},
	Synopsis: "Unmount the virtual filesystem",
	Usages: []string{"tmsu unmount MOUNTPOINT",
		"tmsu unmount --all"},
	Description: "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",
	Usages: []string{"tmsu untag [OPTION]... FILE TAG[=VALUE]...",
		"tmsu untag [OPTION]... --all FILE...",
		`tmsu untag [OPTION]... --tags="TAG[=VALUE]..." FILE...`},
	Description: "Disassociates FILE with the TAGs specified.",
	Examples: []string{"$ tmsu untag mountain.jpg hill county=germany",
		"$ tmsu untag --all mountain-copy.jpg",
		`$ tmsu untag --tags="river underwater year=2017" 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, ""},
		{"--no-dereference", "-P", "do not follow symbolic links (untag the link itself)", false, ""}},
	Exec: untagExec,
}
View Source
var UntaggedCommand = Command{
	Name:     "untagged",
	Synopsis: "List untagged files",
	Usages:   []string{"tmsu untagged [OPTION]... [PATH]..."},
	Description: `Identify untagged files in the filesystem.  

Where PATHs are not specified, untagged items under the current working directory are shown.`,
	Examples: []string{"$ tmsu untagged",
		"$ tmsu untagged /home/fred/drawings"},
	Options: Options{Option{"--directory", "-d", "do not examine directory contents (non-recursive)", false, ""},
		Option{"--count", "-c", "list the number of files rather than their names", false, ""},
		Option{"--no-dereference", "-P", "do not dereference symbolic links", false, ""}},
	Exec: untaggedExec,
}
View Source
var ValuesCommand = Command{
	Name:        "values",
	Synopsis:    "List values",
	Usages:      []string{"tmsu values [OPTION]... [TAG]..."},
	Description: "Lists the values for TAGs. If no TAG is specified then all tags are listed.",
	Examples: []string{"$ tmsu values year\n2000\n2001\n2017",
		"$ tmsu values\n2000\n2001\n2017\ncheese\nopera",
		"$ tmsu values --count year\n3"},
	Options: Options{{"--count", "-c", "lists the number of values rather than their names", false, ""},
		{"", "-1", "list one value per line", false, ""}},
	Exec: valuesExec,
}
View Source
var VersionCommand = Command{
	Name:        "version",
	Synopsis:    "Display the version",
	Usages:      []string{"tmsu version"},
	Description: "Displays version and copyright information.",
	Options:     Options{},
	Exec:        versionExec,
	Hidden:      true,
}
View Source
var VfsCommand = Command{
	Name:     "vfs",
	Synopsis: "Hosts the virtual filesystem",
	Usages:   []string{"tmsu vfs [OPTION]... MOUNTPOINT"},
	Description: `This subcommand is the foreground process which hosts the virtual filesystem. It is run automatically when a virtual filesystem is mounted using the 'mount' subcommand and terminated when the virtual filesystem is unmounted.

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

Functions

func Run

func Run()

Types

type Command

type Command struct {
	Name        string
	Aliases     []string
	Synopsis    string
	Usages      []string
	Description string
	Examples    []string
	Options     Options
	Exec        func(options Options, arguments []string, databasePath string) (error, warnings)
	Hidden      bool
}

type NoSuchTagError

type NoSuchTagError struct {
	Name string
}

func (NoSuchTagError) Error

func (err NoSuchTagError) Error() string

type NoSuchValueError

type NoSuchValueError struct {
	Name string
}

func (NoSuchValueError) Error

func (err NoSuchValueError) Error() string

type Option

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

type OptionParser

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

func NewOptionParser

func NewOptionParser(globalOptions Options, commands []*Command) *OptionParser

func (*OptionParser) Parse

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

type Options

type Options []Option

func (Options) Count

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

type Row struct {
	Path   string
	Status Status
}

type Status

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

type StatusReport

type StatusReport struct {
	Rows []Row
}

func NewReport

func NewReport() *StatusReport

func (*StatusReport) AddRow

func (report *StatusReport) AddRow(row Row)

func (*StatusReport) ContainsRow

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