-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disabled timeline loading for specific CLI actions
- Loading branch information
Showing
3 changed files
with
724 additions
and
722 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
Oops, something went wrong.