mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
small change
This commit is contained in:
parent
8b178881cf
commit
68ddbe7f14
1 changed files with 16 additions and 3 deletions
|
@ -5,7 +5,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -16,6 +15,7 @@ import (
|
||||||
"github.com/schollz/croc/v6/src/models"
|
"github.com/schollz/croc/v6/src/models"
|
||||||
"github.com/schollz/croc/v6/src/tcp"
|
"github.com/schollz/croc/v6/src/tcp"
|
||||||
"github.com/schollz/croc/v6/src/utils"
|
"github.com/schollz/croc/v6/src/utils"
|
||||||
|
log "github.com/schollz/logger"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ func Run() (err error) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
|
cli.BoolFlag{Name: "config", Usage: "save these settings to reuse next time"},
|
||||||
cli.BoolFlag{Name: "debug", Usage: "increase verbosity (a lot)"},
|
cli.BoolFlag{Name: "debug", Usage: "increase verbosity (a lot)"},
|
||||||
cli.BoolFlag{Name: "yes", Usage: "automatically agree to all prompts"},
|
cli.BoolFlag{Name: "yes", Usage: "automatically agree to all prompts"},
|
||||||
cli.BoolFlag{Name: "stdout", Usage: "redirect file to stdout"},
|
cli.BoolFlag{Name: "stdout", Usage: "redirect file to stdout"},
|
||||||
|
@ -95,8 +96,20 @@ func Run() (err error) {
|
||||||
// return croc.SaveDefaultConfig()
|
// return croc.SaveDefaultConfig()
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func send(c *cli.Context) (err error) {
|
func makeConfigDir() (err error) {
|
||||||
|
homedir, err := os.UserHomeDir()
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.SetLevel("debug")
|
||||||
|
log.Debugf("creating home directory %s", homedir)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func send(c *cli.Context) (err error) {
|
||||||
|
makeConfigDir()
|
||||||
|
os.Exit(0)
|
||||||
var fnames []string
|
var fnames []string
|
||||||
stat, _ := os.Stdin.Stat()
|
stat, _ := os.Stdin.Stat()
|
||||||
if (stat.Mode() & os.ModeCharDevice) == 0 {
|
if (stat.Mode() & os.ModeCharDevice) == 0 {
|
||||||
|
@ -116,7 +129,7 @@ func send(c *cli.Context) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
err = os.Remove(fnames[0])
|
err = os.Remove(fnames[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue