Skip to content

Commit

Permalink
Disabled timeline loading for specific CLI actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mrusme committed Jul 12, 2021
1 parent 119356c commit 1abaec6
Show file tree
Hide file tree
Showing 3 changed files with 724 additions and 722 deletions.
78 changes: 40 additions & 38 deletions cli/cmdCmd.go
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
package cli

import (
"fmt"
"strings"
"os"
"fmt"
"os"
"strings"

"github.com/spf13/cobra"
"github.com/rivo/tview"
"github.com/rivo/tview"
"github.com/spf13/cobra"

"github.com/mrusme/gomphotherium/mast"
"github.com/mrusme/gomphotherium/tui"
"github.com/mrusme/gomphotherium/mast"
"github.com/mrusme/gomphotherium/tui"
)

var cmdCmd = &cobra.Command{
Use: "cmd",
Short: "Run command",
Long: "Run command directly from the command line.",
Run: func(cmd *cobra.Command, args []string) {
timeline := mast.NewTimeline(MastodonClient)
cmdReturn := mast.CmdProcessor(
&timeline,
strings.Join(args, " "),
mast.TriggerCLI,
)

switch cmdReturn {
case mast.CodeOk:
timeline.Load()
output, err := tui.RenderTimeline(&timeline, 72, flagShowImages)
if err != nil {
panic(err)
}

fmt.Printf(tview.TranslateANSI(output))
case mast.CodeTriggerNotSupported:
fmt.Printf("Command not supported from CLI!\n")
os.Exit(-1)
default:
fmt.Printf("%v\n", cmdReturn)
os.Exit(-1)
}

return
},
Use: "cmd",
Short: "Run command",
Long: "Run command directly from the command line.",
Run: func(cmd *cobra.Command, args []string) {
timeline := mast.NewTimeline(MastodonClient)
cmdReturn, loadTimeline := mast.CmdProcessor(
&timeline,
strings.Join(args, " "),
mast.TriggerCLI,
)

switch cmdReturn {
case mast.CodeOk:
if loadTimeline == true {
timeline.Load()
output, err := tui.RenderTimeline(&timeline, 72, flagShowImages)
if err != nil {
panic(err)
}

fmt.Printf(tview.TranslateANSI(output))
}
case mast.CodeTriggerNotSupported:
fmt.Printf("Command not supported from CLI!\n")
os.Exit(-1)
default:
fmt.Printf("%v\n", cmdReturn)
os.Exit(-1)
}

return
},
}

func init() {
rootCmd.AddCommand(cmdCmd)
rootCmd.AddCommand(cmdCmd)
}
Loading

0 comments on commit 1abaec6

Please sign in to comment.