Browse Source

updated location of pending file

bmallred 10 years ago
parent
commit
935c8ca2f3
5 changed files with 9 additions and 11 deletions
  1. 2 2
      commandClear.go
  2. 2 2
      commandCommit.go
  3. 2 2
      commandCredit.go
  4. 2 2
      commandDebit.go
  5. 1 3
      commandStatus.go

+ 2 - 2
commandClear.go

1
package main
1
package main
2
2
3
import (
3
import (
4
	"fmt"
4
	"os"
5
	"os"
5
	"path/filepath"
6
6
7
	"github.com/codegangsta/cli"
7
	"github.com/codegangsta/cli"
8
)
8
)
24
24
25
// Clear current pending transaction
25
// Clear current pending transaction
26
func actionClear(c *cli.Context) {
26
func actionClear(c *cli.Context) {
27
	pendingFile := filepath.Join(os.TempDir(), c.String("file"))
27
	pendingFile := fmt.Sprintf(".%s", c.String("file"))
28
	ensureFileExists(pendingFile)
28
	ensureFileExists(pendingFile)
29
29
30
	file, err := os.OpenFile(pendingFile, os.O_TRUNC|os.O_WRONLY, 0666)
30
	file, err := os.OpenFile(pendingFile, os.O_TRUNC|os.O_WRONLY, 0666)

+ 2 - 2
commandCommit.go

2
2
3
import (
3
import (
4
	"errors"
4
	"errors"
5
	"fmt"
5
	"io/ioutil"
6
	"io/ioutil"
6
	"os"
7
	"os"
7
	"path/filepath"
8
	"strings"
8
	"strings"
9
	"time"
9
	"time"
10
10
36
	ledgerFile := c.String("file")
36
	ledgerFile := c.String("file")
37
	ensureFileExists(ledgerFile)
37
	ensureFileExists(ledgerFile)
38
38
39
	pendingFile := filepath.Join(os.TempDir(), c.String("file"))
39
	pendingFile := fmt.Sprintf(".%s", c.String("file"))
40
	ensureFileExists(pendingFile)
40
	ensureFileExists(pendingFile)
41
41
42
	date, err := parseDate(c.String("date"))
42
	date, err := parseDate(c.String("date"))

+ 2 - 2
commandCredit.go

1
package main
1
package main
2
2
3
import (
3
import (
4
	"fmt"
4
	"os"
5
	"os"
5
	"path/filepath"
6
6
7
	"github.com/codegangsta/cli"
7
	"github.com/codegangsta/cli"
8
)
8
)
24
24
25
// Add a credit to the pending transaction
25
// Add a credit to the pending transaction
26
func actionCredit(c *cli.Context) {
26
func actionCredit(c *cli.Context) {
27
	pendingFile := filepath.Join(os.TempDir(), c.String("file"))
27
	pendingFile := fmt.Sprintf(".%s", c.String("file"))
28
	ensureFileExists(pendingFile)
28
	ensureFileExists(pendingFile)
29
29
30
	args := c.Args()
30
	args := c.Args()

+ 2 - 2
commandDebit.go

1
package main
1
package main
2
2
3
import (
3
import (
4
	"fmt"
4
	"os"
5
	"os"
5
	"path/filepath"
6
6
7
	"github.com/codegangsta/cli"
7
	"github.com/codegangsta/cli"
8
)
8
)
24
24
25
// Add a debit to the pending transaction
25
// Add a debit to the pending transaction
26
func actionDebit(c *cli.Context) {
26
func actionDebit(c *cli.Context) {
27
	pendingFile := filepath.Join(os.TempDir(), c.String("file"))
27
	pendingFile := fmt.Sprintf(".%s", c.String("file"))
28
	ensureFileExists(pendingFile)
28
	ensureFileExists(pendingFile)
29
29
30
	args := c.Args()
30
	args := c.Args()

+ 1 - 3
commandStatus.go

3
import (
3
import (
4
	"fmt"
4
	"fmt"
5
	"io/ioutil"
5
	"io/ioutil"
6
	"os"
7
	"path/filepath"
8
6
9
	"github.com/codegangsta/cli"
7
	"github.com/codegangsta/cli"
10
)
8
)
26
24
27
// Display the current status of the ledger
25
// Display the current status of the ledger
28
func actionStatus(c *cli.Context) {
26
func actionStatus(c *cli.Context) {
29
	pendingFile := filepath.Join(os.TempDir(), c.String("file"))
27
	pendingFile := fmt.Sprintf(".%s", c.String("file"))
30
	ensureFileExists(pendingFile)
28
	ensureFileExists(pendingFile)
31
29
32
	if hasPendingTransaction(pendingFile) {
30
	if hasPendingTransaction(pendingFile) {