Skip to content

Commit

Permalink
Merge pull request #31 from as27/dev
Browse files Browse the repository at this point in the history
#17 documentation #29 verbose mode
  • Loading branch information
as27 authored Oct 25, 2020
2 parents dbfa07a + c3f2185 commit 1819eed
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# gomd

* A Prototype of file browser for command line.
_Important: This tool is a prototype and not production ready! Use it play with it and send some feedback. Just open an issue at github for this._

* A prototype of file browser for command line.

* Main Motive:
* To use tview and create something useful.
Expand Down Expand Up @@ -38,4 +40,14 @@ At the moment there are following commands implemented:
* `move`, `mv`: moves the file from the left to the right side
* `remove`, `rm`: removes the file from the right side
* `mkdir [dirname]`, `makedir [dirname]`: creates that folder on the left side
* `q`, `quit`: exits the app
* `q`, `quit`: exits the app

## Installation

This tool is written in Go. For a fast installation just run

`go get github.com/as27/gomd/cmd/gomd`

To update just type

`go get -u github.com/as27/gomd/cmd/gomd`
11 changes: 9 additions & 2 deletions cmd/gomd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

type app struct {
conf appConf
files gocmd.Files
view *tview.Application
root tview.Primitive
Expand All @@ -26,6 +27,10 @@ type app struct {
appOut io.Writer
}

type appConf struct {
verbose bool
}

// newApp contains the initial configuration
func newApp() *app {
left, err := gocmd.NewFolder("./")
Expand Down Expand Up @@ -85,8 +90,10 @@ func (a *app) run() error {
AddItem(a.right, 0, 2, false),
0, 2, true).
AddItem(a.cmd, 1, 1, false).
AddItem(a.bottom, 2, 1, false).
AddItem(a.log, 4, 1, false)
AddItem(a.bottom, 2, 1, false)
if a.conf.verbose {
root = root.AddItem(a.log, 4, 1, false)
}
//root.SetBorder(true)
root.SetTitle("gomd")
a.root = root
Expand Down
15 changes: 14 additions & 1 deletion cmd/gomd/main.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
package main

import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
)

var (
flagVerbose = flag.Bool("verbose", false, "start in verbose mode. Will print internal logs in the app. Use this for debugging purposes.")
)

func main() {
flag.Parse()
a := newApp()
w, ok := a.log.(io.Writer)
if ok {
log.SetOutput(w)
if *flagVerbose {
log.SetOutput(w)
}
}
if !*flagVerbose {
log.SetOutput(ioutil.Discard)
}
a.conf.verbose = *flagVerbose
err := a.run()
if err != nil {
fmt.Fprintln(os.Stderr, "error running the app: ", err)
Expand Down

0 comments on commit 1819eed

Please sign in to comment.