This repository was archived by the owner on Jan 10, 2023. It is now read-only.
File tree 2 files changed +4
-19
lines changed
2 files changed +4
-19
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import (
12
12
13
13
// TODO: set exit code (project-wide)
14
14
func rm (c * cli.Context ) error {
15
- fmt .Println ("I am in rm!" )
16
15
slug := c .Args ().First ()
17
16
18
17
record , err := ledger .GetBySlug (slug )
Original file line number Diff line number Diff line change @@ -43,20 +43,12 @@ func GetRecords() ([]Record, error) {
43
43
44
44
func GetBySlug (slug string ) (Record , error ) {
45
45
var match Record
46
- var ledger Records
47
46
48
- // TODO: use getrecords
49
- b , err := ioutil .ReadFile (Path ())
47
+ records , err := GetRecords ()
50
48
if err != nil {
51
49
return match , err
52
50
}
53
- str := string (b )
54
-
55
- if _ , err := toml .Decode (str , & ledger ); err != nil {
56
- return match , err
57
- }
58
-
59
- for _ , r := range ledger .Record {
51
+ for _ , r := range records {
60
52
if strings .Contains (r .Slug , slug ) {
61
53
return r , nil
62
54
}
@@ -71,19 +63,13 @@ func (r Record) String() string {
71
63
72
64
// comparison by Path
73
65
func (r Record ) RemoveFromLedger () error {
74
- b , err := ioutil . ReadFile ( Path () )
66
+ records , err := GetRecords ( )
75
67
if err != nil {
76
68
return err
77
69
}
78
- str := string (b )
79
-
80
- var ledger Records
81
- if _ , err := toml .Decode (str , & ledger ); err != nil {
82
- return err
83
- }
84
70
85
71
var content string
86
- for _ , s := range ledger . Record {
72
+ for _ , s := range records {
87
73
if s .Path != r .Path {
88
74
content = content + s .String () + "\n "
89
75
}
You can’t perform that action at this time.
0 commit comments