Documentation ¶
Overview ¶
Package cmd contains all the commands for TEMPest.
Copyright © 2018 Sebastien Bastide Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Variables
- func Execute()
- func FormatSize(incomingSize float64) (size float64, unit string)
- func IsDirectory(path string) (bool, error)
- func IsIntInSlice(index int, sl []int) bool
- func IsStringInSlice(str string, sl []string) bool
- func Round(val float64, roundOn float64, places int) (newVal float64)
- func SameSliceValuesStr(a, b []string) bool
- func SameSlices(a, b []string) bool
- func SameSlicesInt(a, b []int) bool
- func TreatLastChar(str string) string
- func WriteLog(pathLog string, strs ...string)
- type Target
Constants ¶
This section is empty.
Variables ¶
var CurrTime = time.Now().String()
CurrTime is the current time
FooterLog is the footer for logs
var HeaderLog = "========================= - [" + CurrTime + "] - ========================="
HeaderLog is the header for logs
var LinuxAutoStartP string
LinuxAutoStartP is the path to $HOME/.config/autostart/tempest.desktop which is initialized in init()
var LogShutup string
LogShutup is the path to the log of the 'shutup mode'
var RootCmd = &cobra.Command{ Use: "tempest", Short: "TEMPest is a simple CLI to manage temporary directories.", Long: `TEMPest is a simple CLI to manage temporary directories. It is still under development, so it's normal if it's not perfect .. YET! You can start by checking if the config file exists at: ~/.tempest/.tempest.yaml It contains the files' contraint of age (duration in days). It also contains the mode (auto or manual) in which TEMPest runs. /!\ note that Windows hasn't been fully tested. Then you can initialize the list of directories handled by TEMPest. For example: tempest init Then change directory (cd) to a directory you desire to add, and run: tempest add Or just specify the path to the directory (you can add multiple). For example: tempest add /tmp/temp.est /temp/test.est # Note that, by convention, the tempory directories will be called 'temp.est' To start cleaning targets directories just run: tempest start Or if you want to see what files/folders would get deleted: tempest start -t `, Run: func(cmd *cobra.Command, args []string) { switch { case isVersion: if version, errVersion := getVersion(); errVersion != nil { color.Red(errVersion.Error()) } else { fmt.Println(color.HiYellowString(version)) } default: if errHelp := cmd.Help(); errHelp != nil { color.Red(errHelp.Error()) } } }, }
RootCmd represents the base command when called without any subcommands TODO Make full description with full help on how to use the CLI
var Slash = string(os.PathSeparator)
Slash is shorthand for the path separator
var TempestConfigDir string
TempestConfigDir points to the config directory of TEMPest it holds pretty much all configuration for TEMPest
var Tempestcf string
Tempestcf is the path to the .tempestcf file this file holds all the paths (targets) of TEMPest
var Tempestyml string
Tempestyml is the path to the .tempest.yaml file which olds all the the config for the TEMPest tool
var TempestymlDef string
TempestymlDef is the default path to the .tempest.yaml file use it wisely.
var WindowsAutoStartSL string
WindowsAutoStartSL is the path to "%AppData%\Microsoft\Windows\Start Menu\Programs\Startup\tempest". which is a Symlink to the scripts/startup.bat file, initialized in init()
Functions ¶
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func FormatSize ¶
FormatSize takes the size in Bytes and return the new size converted in KByte, MBytes, GBytes when it needs to, plus the unit.
func IsDirectory ¶
IsDirectory returns true if this path points to a directory If there is an error, the func will return it
func IsIntInSlice ¶
IsIntInSlice returns true if the int is in the slice
func IsStringInSlice ¶
IsStringInSlice returns true if the string is in the slice. This one is more simple and faster than checkRedondance(slice, sliceArgs[]string) bool
func SameSliceValuesStr ¶
SameSliceValuesStr returns “true“ if the two slices fo “string“ have the same values, order doesn't matter
func SameSlices ¶
SameSlices checks equality between two slices of string returns true if they are identiques
func SameSlicesInt ¶
SameSlicesInt checks equality between two slices of int returns true if they are identiques
func TreatLastChar ¶
TreatLastChar takes a string as parameter. It analyzes the last character of this string, if it is a path separator character, it gets removed. Returns the new path, wether there was change or not.
Types ¶
type Target ¶
Target is represented by an index and a path Later this will hold the type(directory or file)
func PathsToTargets ¶
PathsToTargets is a converter, takes paths (strings) and convert them into targets (Target)