-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb548a4
commit 1d77009
Showing
5 changed files
with
109 additions
and
55 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,62 +1,9 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
stplatform "github.com/StevenSermeus/anime-tui/st_platform" | ||
"github.com/StevenSermeus/anime-tui/tui" | ||
"github.com/StevenSermeus/anime-tui/cmd" | ||
) | ||
|
||
func main() { | ||
mav := &stplatform.Mavanimes{} | ||
state := "menu" | ||
quit := false | ||
anime_state := stplatform.Anime{} | ||
for !quit { | ||
switch state { | ||
case "menu": | ||
state, quit = tui.Menu() | ||
case "Recherche": | ||
anime, isRetunring, isQuiting, err := tui.Search(mav) | ||
if err != nil { | ||
fmt.Println("Error searching anime:", err) | ||
os.Exit(1) | ||
} | ||
if isQuiting { | ||
quit = true | ||
continue | ||
} | ||
if isRetunring { | ||
state = "menu" | ||
continue | ||
} | ||
anime_state = anime | ||
state = "Episodes" | ||
case "Nouveautés": | ||
isRetunring, isQuiting, err := tui.Newest(mav) | ||
if err != nil { | ||
fmt.Println("Error getting newest anime:", err) | ||
os.Exit(1) | ||
} | ||
if isRetunring { | ||
state = "menu" | ||
continue | ||
} | ||
quit = isQuiting | ||
case "Episodes": | ||
isRetunring, isQuiting, err := tui.Episodes(mav, anime_state) | ||
if err != nil { | ||
fmt.Println("Error getting episodes:", err) | ||
os.Exit(1) | ||
} | ||
if isRetunring { | ||
state = "Recherche" | ||
continue | ||
} | ||
quit = isQuiting | ||
} | ||
|
||
} | ||
|
||
cmd.Execute() | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "anime-tui", | ||
Short: "A terminal user interface for anime", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println("This is the root command") | ||
}, | ||
} | ||
|
||
var versionCmd = &cobra.Command{ | ||
Use: "version", | ||
Short: "Print the version number of anime-tui", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
// Only change when the tag is changed | ||
// When in othen branch than main put as -dev | ||
fmt.Println("0.0.1-beta") | ||
}, | ||
} | ||
|
||
func Execute() { | ||
rootCmd.AddCommand(versionCmd) | ||
if err := rootCmd.Execute(); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package tui | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
stplatform "github.com/StevenSermeus/anime-tui/st_platform" | ||
) | ||
|
||
func StartTui() { | ||
mav := &stplatform.Mavanimes{} | ||
state := "menu" | ||
quit := false | ||
anime_state := stplatform.Anime{} | ||
for !quit { | ||
switch state { | ||
case "menu": | ||
state, quit = Menu() | ||
case "Recherche": | ||
anime, isRetunring, isQuiting, err := Search(mav) | ||
if err != nil { | ||
fmt.Println("Error searching anime:", err) | ||
os.Exit(1) | ||
} | ||
if isQuiting { | ||
quit = true | ||
continue | ||
} | ||
if isRetunring { | ||
state = "menu" | ||
continue | ||
} | ||
anime_state = anime | ||
state = "Episodes" | ||
case "Nouveautés": | ||
isRetunring, isQuiting, err := Newest(mav) | ||
if err != nil { | ||
fmt.Println("Error getting newest anime:", err) | ||
os.Exit(1) | ||
} | ||
if isRetunring { | ||
state = "menu" | ||
continue | ||
} | ||
quit = isQuiting | ||
case "Episodes": | ||
isRetunring, isQuiting, err := Episodes(mav, anime_state) | ||
if err != nil { | ||
fmt.Println("Error getting episodes:", err) | ||
os.Exit(1) | ||
} | ||
if isRetunring { | ||
state = "Recherche" | ||
continue | ||
} | ||
quit = isQuiting | ||
} | ||
|
||
} | ||
} |