Paul Ruane avatar Paul Ruane committed df600c1

Fixed formatting problems.
Updated Zsh completion with database short option change (-d to -D).

Comments (0)

Files changed (10)

 	_arguments -C \
 	    {--verbose,-v}'[show verbose messages]' \
 	    {--version,-V}'[show version information and exit]' \
-	    {--database=,-d}'[use the specified database]:file:_files' \
+	    {--database=,-D}'[use the specified database]:file:_files' \
 	    {--help,-h}'[show help and exit]' \
 		': :_tmsu_commands' \
 		'*::arg:->args' \

src/tmsu/cli/cli.go

 		commandName = "help"
 	}
 
-	if options.HasOption("--verbose") {
-		log.Verbosity = 2
-	}
+	log.Verbosity = options.Count("--verbose") + 1
+
 	if dbOption := options.Get("--database"); dbOption != nil && dbOption.Argument != "" {
 		database.Path = dbOption.Argument
 	}

src/tmsu/cli/dupes.go

 
 	for index, fileSet := range fileSets {
 		if index > 0 {
-			fmt.Print()
+			fmt.Println()
 		}
 
-		fmt.Printf("Set of %v duplicates:", len(fileSet))
+		fmt.Printf("Set of %v duplicates: %v\n", len(fileSet))
 
 		for _, file := range fileSet {
 			relPath := _path.Rel(file.Path())
-			fmt.Printf("  %v", relPath)
+			fmt.Printf("  %v\n", relPath)
 		}
 	}
 
 			if first {
 				first = false
 			} else {
-				fmt.Print()
+				fmt.Println()
 			}
 
-			fmt.Printf("%v:", path)
+			fmt.Printf("%v:\n", path)
 
 			for _, dupe := range dupes {
 				relPath := _path.Rel(dupe.Path())
-				fmt.Printf("  %v", relPath)
+				fmt.Printf("  %v\n", relPath)
 			}
 		} else {
 			for _, dupe := range dupes {
 				relPath := _path.Rel(dupe.Path())
-				fmt.Print(relPath)
+				fmt.Println(relPath)
 			}
 		}
 	}

src/tmsu/cli/files.go

 	}
 
 	if showCount {
-		fmt.Print(len(tree.Paths()))
+		fmt.Println(len(tree.Paths()))
 	} else {
 		for _, absPath := range tree.Paths() {
 			relPath := path.Rel(absPath)
 			if print0 {
 				fmt.Printf("%v\000", relPath)
 			} else {
-				fmt.Print(relPath)
+				fmt.Println(relPath)
 			}
 		}
 	}

src/tmsu/cli/mount.go

 	}
 
 	for _, mount := range mt {
-		fmt.Printf("'%v' at '%v'", mount.DatabasePath, mount.MountPath)
+		fmt.Printf("'%v' at '%v'\n", mount.DatabasePath, mount.MountPath)
 	}
 
 	return nil

src/tmsu/cli/option.go

 	return false
 }
 
+func (options Options) Count(name string) uint {
+	var count uint = 0
+
+	for _, option := range options {
+		if option.LongName == name || option.ShortName == name {
+			count++
+		}
+	}
+
+	return count
+}
+
 func (options Options) Get(name string) *Option {
 	for _, option := range options {
 		if option.LongName == name || option.ShortName == name {

src/tmsu/cli/status.go

 }
 
 func printRow(row Row) {
-	fmt.Printf("%v %v", string(row.Status), row.Path)
+	fmt.Printf("%v %v\n", string(row.Status), row.Path)
 }

src/tmsu/cli/tags.go

 			return fmt.Errorf("could not retrieve tag count: %v", err)
 		}
 
-		fmt.Print(count)
+		fmt.Println(count)
 	} else {
 		tags, err := store.Tags()
 		if err != nil {
 		}
 
 		for _, tag := range tags {
-			fmt.Print(tag.Name)
+			fmt.Println(tag.Name)
 		}
 	}
 
 	}
 
 	if showCount {
-		fmt.Print(len(tags))
+		fmt.Println(len(tags))
 	} else {
 		for _, tag := range tags {
-			fmt.Print(tag.Name)
+			fmt.Println(tag.Name)
 		}
 	}
 
 		}
 
 		if showCount {
-			fmt.Print(path + ": " + strconv.Itoa(len(tags)))
+			fmt.Println(path + ": " + strconv.Itoa(len(tags)))
 		} else {
-			fmt.Print(path + ": " + formatTags(tags))
+			fmt.Println(path + ": " + formatTags(tags))
 		}
 	}
 
 		}
 
 		if showCount {
-			fmt.Print(dirName + ": " + strconv.Itoa(len(tags)))
+			fmt.Println(dirName + ": " + strconv.Itoa(len(tags)))
 		} else {
-			fmt.Print(dirName + ": " + formatTags(tags))
+			fmt.Println(dirName + ": " + formatTags(tags))
 		}
 	}
 

src/tmsu/cli/version.go

 }
 
 func versionExec(options Options, args []string) error {
-	fmt.Print("TMSU", common.Version)
-	fmt.Print()
-	fmt.Print(`Copyright © 2011-2013 Paul Ruane.
+	fmt.Println("TMSU", common.Version)
+	fmt.Println()
+	fmt.Println(`Copyright © 2011-2013 Paul Ruane.
 
 This program comes with ABSOLUTELY NO WARRANTY.
 This is free software, and you are welcome to redistribute it under certain conditions.

src/tmsu/log/log.go

 
 var Outfile = os.Stdout
 var Errfile = os.Stderr
-var Verbosity = 1
+var Verbosity uint = 1
 
 func Fatal(values ...interface{}) {
 	Warn(values...)
 }
 
 func Info(verbosity uint, values ...interface{}) {
+	if verbosity > Verbosity {
+		return
+	}
+
 	fmt.Fprintf(Outfile, "tmsu: ")
 	fmt.Fprintln(Outfile, values...)
 }
 
 func Infof(verbosity uint, format string, values ...interface{}) {
+	if verbosity > Verbosity {
+		return
+	}
+
 	format = "tmsu: " + format + "\n"
 	fmt.Fprintf(Outfile, format, values...)
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.