refactor(cli): perform code clean up
This commit is contained in:
parent
7d4a54b34c
commit
b18b7761fc
1 changed files with 2 additions and 24 deletions
|
|
@ -40,28 +40,6 @@ const (
|
||||||
historyFileName = "sst_history"
|
historyFileName = "sst_history"
|
||||||
)
|
)
|
||||||
|
|
||||||
// func LogToHistory(action, pkg, manager string) error {
|
|
||||||
// dirname, err := os.UserConfigDir()
|
|
||||||
// if err != nil {
|
|
||||||
// return fmt.Errorf("cant obtain config dir: %v", err)
|
|
||||||
// }
|
|
||||||
// historyFile := filepath.Join(dirname, "sst", "sst_history")
|
|
||||||
// f, err := os.OpenFile(historyFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
|
||||||
// if err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
// defer f.Close()
|
|
||||||
|
|
||||||
// timestamp := time.Now().Format("2006-01-02 15:04:05")
|
|
||||||
// logEntry := fmt.Sprintf("%s: action: [%s] - package: [%s] - packagemanager: [%s]\n", timestamp, action, pkg, manager)
|
|
||||||
|
|
||||||
// if _, err := f.WriteString(logEntry); err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
func LogToHistory(action, pkg, manager string) error {
|
func LogToHistory(action, pkg, manager string) error {
|
||||||
dirname, err := os.UserConfigDir()
|
dirname, err := os.UserConfigDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -75,8 +53,8 @@ func LogToHistory(action, pkg, manager string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp := time.Now().Format("2006-01-02 15:04:05")
|
timestamp := time.Now().Format("2006-01-02 15:04:05")
|
||||||
newLine := fmt.Sprintf("%s: action: [%s] - package: [%s] - packagemanager: [%s]", timestamp, action, pkg, manager)
|
logEntry := fmt.Sprintf("%s: action: [%s] - package: [%s] - packagemanager: [%s]", timestamp, action, pkg, manager)
|
||||||
lines = append(lines, newLine)
|
lines = append(lines, logEntry)
|
||||||
|
|
||||||
if len(lines) > maxHistoryLines {
|
if len(lines) > maxHistoryLines {
|
||||||
lines = lines[len(lines)-maxHistoryLines:]
|
lines = lines[len(lines)-maxHistoryLines:]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue