# HG changeset patch # User Peter Sanchez # Date 1615653200 28800 # Sat Mar 13 08:33:20 2021 -0800 # Node ID 2b6a41561707ef93dc1e0f7b9897fe5702892ae1 # Parent 59f8720f5a1730a92a4b4f3884131b7ecf97daa4 Added flag to disable relative path display. diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Flags: -d, --database string Path to SQLite3 database file. (default "~/.tago/tago.db") + -f, --fullpath Use full path for all files (disabled relative path display.) -h, --help help for tago -v, --version version for tago diff --git a/cmd/helpers.go b/cmd/helpers.go --- a/cmd/helpers.go +++ b/cmd/helpers.go @@ -91,6 +91,11 @@ // RelativePath shows relative path from the current directory func RelativePath(path string) string { + if fullPath { + // Do not use relative path with fullPath is switched on + return path + } + addSep := func(path string) string { if path[len(path)-1] == filepath.Separator { return path diff --git a/cmd/root.go b/cmd/root.go --- a/cmd/root.go +++ b/cmd/root.go @@ -6,7 +6,10 @@ "github.com/spf13/cobra" ) -var dbFile string +var ( + dbFile string + fullPath bool +) var rootCmd = &cobra.Command{ Use: "tago", @@ -20,6 +23,10 @@ &dbFile, "database", "d", "~/.tago/tago.db", "Path to SQLite3 database file.", ) + rootCmd.PersistentFlags().BoolVarP( + &fullPath, "fullpath", "f", false, + "Use full path for all files (disabled relative path display.)", + ) } // Execute main cobra caller