<commit_before>package cmd

import (
	"fmt"
	"os"
	"time"

	"github.com/spf13/cobra"
	"github.com/spf13/viper"
	"github.com/ttacon/chalk"
)

var EffectiveTimeNow = time.Now() //.round(time.Minute)

var cfgFile string
var Clockfile string
var ModifyEffectiveTime time.Duration

var Debug bool

func D(args ...interface{}) {
	//if viper.GetBool("debug") {
	if Debug {
		//log.Println(chalk.Cyan.Color(fmt.Sprint(args...)))
		fmt.Println(chalk.Cyan.Color(fmt.Sprint(args...)))
	}
}

func GetEffectiveTime() time.Time {
	effectiveTimeNow := time.Now()

	//if ModifyEffectiveTime != nil {
	effectiveTimeNow = effectiveTimeNow.Add(-ModifyEffectiveTime).Round(time.Minute)
	//}
	// Rounding is not performed during entry
	//if roundTime != nil {
	//effectiveTimeNow = effectiveTimeNow.Round(RoundTime)
	//}
	D("Effective time: " + effectiveTimeNow.Format("2006-01-02 15:04"))
	return effectiveTimeNow
}

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
	Use:   "p",
	Short: "Punch or short 'p': A flexible time tracker and time reporting tool",
	Long: `Punch or short 'p': A flexible time tracker and time reporting tool.
made by (and mainly for) <NAME>.

Use this tool to keep track of time spent on projects, assignments, work, etc.
Apart from registering the time periods in a database you
can use this to perform simple todo, logging and reporting on the data.`,
}

// Execute adds all child commands to the root command sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
	if err := RootCmd.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(-1)
	}
}

func init() {
	cobra.OnInitialize(initConfig)

	// Here you will define your flags and configuration settings.
	// Cobra supports Persistent Flags, which, if defined here,
	// will be global for your application.

	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.punch.yaml)")
	RootCmd.PersistentFlags().StringVarP(&Clockfile, "clockfile", "c", "", "Path to the clockfile = time entry database")
	RootCmd.PersistentFlags().BoolVarP(&Debug, "debug", "D", false, "Enables debug output")
	RootCmd.PersistentFlags().DurationVarP(&ModifyEffectiveTime, "mod", "m", time.Duration(0), "modify effective time (backwards), eg 7m subtracts 7 minutes")
	// Cobra also supports local flags, which will only run
	// when this action is called directly.
	//RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
	viper.BindPFlag("clockfile", RootCmd.PersistentFlags().Lookup("clockfile"))
	viper.BindPFlag("debug", RootCmd.PersistentFlags().Lookup("debug"))
	//fmt.Println("2clockfile=", viper.GetString("clockfile"))
}

// initConfig reads in config file and ENV variables if set.
func initConfig() {
	if cfgFile != "" { // enable ability to specify config file via flag
		viper.SetConfigFile(cfgFile)
	}

	viper.SetConfigName("punch")                                    // name of config file (without extension)
	viper.AddConfigPath(".")                                        //current
	viper.AddConfigPath("$HOME/.config")                            //config directory
	viper.AddConfigPath("$HOME")                                    // adding home directory as first search path
	if userprofile := os.Getenv("USERPROFILE"); userprofile != "" { //Windows
		viper.AddConfigPath(os.Getenv(userprofile))
	}
	//viper.AutomaticEnv()         // read in environment variables that match

	// If a config file is found, read it in.
	if err := viper.ReadInConfig(); err == nil {
		D("Using config file: " + viper.ConfigFileUsed())
	}
	//RootCmd.DebugFlags()
}<commit_msg>fixed pathbugg<commit_after>package cmd

import (
	"fmt"
	"os"
	"time"

	"github.com/spf13/cobra"
	"github.com/spf13/viper"
	"github.com/ttacon/chalk"
)

var EffectiveTimeNow = time.Now() //.round(time.Minute)

var cfgFile string
var Clockfile string
var ModifyEffectiveTime time.Duration

var Debug bool

func D(args ...interface{}) {
	//if viper.GetBool("debug") {
	if Debug {
		//log.Println(chalk.Cyan.Color(fmt.Sprint(args...)))
		fmt.Println(chalk.Cyan.Color(fmt.Sprint(args...)))
	}
}

func GetEffectiveTime() time.Time {
	effectiveTimeNow := time.Now()

	//if ModifyEffectiveTime != nil {
	effectiveTimeNow = effectiveTimeNow.Add(-ModifyEffectiveTime).Round(time.Minute)
	//}
	// Rounding is not performed during entry
	//if roundTime != nil {
	//effectiveTimeNow = effectiveTimeNow.Round(RoundTime)
	//}
	D("Effective time: " + effectiveTimeNow.Format("2006-01-02 15:04"))
	return effectiveTimeNow
}

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
	Use:   "p",
	Short: "Punch or short 'p': A flexible time tracker and time reporting tool",
	Long: `Punch or short 'p': A flexible time tracker and time reporting tool.
made by (and mainly for) <NAME>.

Use this tool to keep track of time spent on projects, assignments, work, etc.
Apart from registering the time periods in a database you
can use this to perform simple todo, logging and reporting on the data.`,
}

// Execute adds all child commands to the root command sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
	if err := RootCmd.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(-1)
	}
}

func init() {
	cobra.OnInitialize(initConfig)

	// Here you will define your flags and configuration settings.
	// Cobra supports Persistent Flags, which, if defined here,
	// will be global for your application.

	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.punch.yaml)")
	RootCmd.PersistentFlags().StringVarP(&Clockfile, "clockfile", "c", "", "Path to the clockfile = time entry database")
	RootCmd.PersistentFlags().BoolVarP(&Debug, "debug", "D", false, "Enables debug output")
	RootCmd.PersistentFlags().DurationVarP(&ModifyEffectiveTime, "mod", "m", time.Duration(0), "modify effective time (backwards), eg 7m subtracts 7 minutes")
	// Cobra also supports local flags, which will only run
	// when this action is called directly.
	//RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
	viper.BindPFlag("clockfile", RootCmd.PersistentFlags().Lookup("clockfile"))
	viper.BindPFlag("debug", RootCmd.PersistentFlags().Lookup("debug"))
	//fmt.Println("2clockfile=", viper.GetString("clockfile"))
}

// initConfig reads in config file and ENV variables if set.
func initConfig() {
	if cfgFile != "" { // enable ability to specify config file via flag
		viper.SetConfigFile(cfgFile)
	}

	viper.SetConfigName("punch")                                    // name of config file (without extension)
	viper.AddConfigPath(".")                                        //current
	viper.AddConfigPath("$HOME/.config")                            //config directory
	viper.AddConfigPath("$HOME")                                    // adding home directory as first search path
	if userprofile := os.Getenv("USERPROFILE"); userprofile != "" { //Windows
		viper.AddConfigPath(userprofile)
	}
	//viper.AutomaticEnv()         // read in environment variables that match

	// If a config file is found, read it in.
	if err := viper.ReadInConfig(); err == nil {
		D("Using config file: " + viper.ConfigFileUsed())
	}
	//RootCmd.DebugFlags()
}
{'fraction_non_alphanumeric': 0.1309362279511533, 'fraction_numerical': 0.005698778833107192, 'mean_word_length': 3.6271186440677967, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5576965', 'n_tokens_mistral': 2317, 'n_tokens_neox': 2249, 'n_words': 693}