summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Czapliński <czapkofan@gmail.com>2018-10-26 00:11:17 +0200
committerMateusz Czapliński <czapkofan@gmail.com>2018-10-26 00:12:50 +0200
commit39d38fae05bfdd678760b173b68b6c7dd51881c1 (patch)
tree8a15cb71273c79eded473da4092101ee04754844
parentb04907d9a4b39f4e60af49f1b0802baf14c79665 (diff)
parent0181b7ee7ee92c3b76fe2043e70c86ee17384c2d (diff)
Merge branch 'pr3'
-rw-r--r--AUTHORS4
-rw-r--r--up.go26
2 files changed, 16 insertions, 14 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..c7f2ac2
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,4 @@
+Please keep the contents of this file sorted alphabetically.
+
+Mateusz Czapliński <czapkofan@gmail.com>
+Rohan Verma <hello@rohanverma.net>
diff --git a/up.go b/up.go
index 4eb68ee..7e17bc9 100644
--- a/up.go
+++ b/up.go
@@ -1,4 +1,4 @@
-// Copyright 2018 The up Authors
+// Copyright 2018 The up AUTHORS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -74,12 +74,21 @@ var (
// FIXME(akavel): mark the unsafe mode vs. safe mode with some colour or status; also inform/mark what command's results are displayed...
unsafeMode = pflag.Bool("unsafe-full-throttle", false, "enable mode in which command is executed immediately after any change")
outputScript = pflag.StringP("output-script", "o", "", "save the command to specified `file` if Ctrl-X is pressed (default: up<N>.sh)")
+ debugMode = pflag.Bool("debug", false, "debug mode")
)
func main() {
- pflag.Parse()
// Handle command-line flags
- parseFlags()
+ pflag.Parse()
+
+ log.SetOutput(ioutil.Discard)
+ if *debugMode {
+ debug, err := os.Create("up.debug")
+ if err != nil {
+ die(err.Error())
+ }
+ log.SetOutput(debug)
+ }
// Initialize TUI infrastructure
tui := initTUI()
@@ -193,17 +202,6 @@ func main() {
}
}
-func parseFlags() {
- log.SetOutput(ioutil.Discard)
- if len(os.Args) > 1 && os.Args[1] == "--debug" {
- debug, err := os.Create("up.debug")
- if err != nil {
- die(err.Error())
- }
- log.SetOutput(debug)
- }
-}
-
func initTUI() tcell.Screen {
// TODO: Without below block, we'd hang when nothing is piped on input (see
// github.com/peco/peco, mattn/gof, fzf, etc.)