This repository was archived by the owner on Jan 10, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +4
-19
lines changed Expand file tree Collapse file tree 2 files changed +4
-19
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import (
1212
1313// TODO: set exit code (project-wide)
1414func rm (c * cli.Context ) error {
15- fmt .Println ("I am in rm!" )
1615 slug := c .Args ().First ()
1716
1817 record , err := ledger .GetBySlug (slug )
Original file line number Diff line number Diff line change @@ -43,20 +43,12 @@ func GetRecords() ([]Record, error) {
4343
4444func GetBySlug (slug string ) (Record , error ) {
4545 var match Record
46- var ledger Records
4746
48- // TODO: use getrecords
49- b , err := ioutil .ReadFile (Path ())
47+ records , err := GetRecords ()
5048 if err != nil {
5149 return match , err
5250 }
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 {
6052 if strings .Contains (r .Slug , slug ) {
6153 return r , nil
6254 }
@@ -71,19 +63,13 @@ func (r Record) String() string {
7163
7264// comparison by Path
7365func (r Record ) RemoveFromLedger () error {
74- b , err := ioutil . ReadFile ( Path () )
66+ records , err := GetRecords ( )
7567 if err != nil {
7668 return err
7769 }
78- str := string (b )
79-
80- var ledger Records
81- if _ , err := toml .Decode (str , & ledger ); err != nil {
82- return err
83- }
8470
8571 var content string
86- for _ , s := range ledger . Record {
72+ for _ , s := range records {
8773 if s .Path != r .Path {
8874 content = content + s .String () + "\n "
8975 }
You can’t perform that action at this time.
0 commit comments