-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(targetflag): target flags added to support different application…
… and platforms
- Loading branch information
mj
committed
Jun 28, 2024
1 parent
7eb001a
commit e933222
Showing
23 changed files
with
291 additions
and
64 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
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
File renamed without changes.
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,54 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
|
||
"github.com/pagu-project/Pagu/internal/engine" | ||
|
||
"github.com/pagu-project/Pagu/internal/platforms/discord" | ||
"github.com/pagu-project/Pagu/pkg/log" | ||
|
||
pCmd "github.com/pagu-project/Pagu/cmd" | ||
"github.com/pagu-project/Pagu/config" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func runCommand(parentCmd *cobra.Command) { | ||
run := &cobra.Command{ | ||
Use: "run", | ||
Short: "Runs a mainnet instance of Pagu for Discord", | ||
} | ||
|
||
parentCmd.AddCommand(run) | ||
|
||
run.Run = func(cmd *cobra.Command, _ []string) { | ||
// load configuration. | ||
configs, err := config.Load(configPath) | ||
pCmd.ExitOnError(cmd, err) | ||
|
||
// Initialize global logger. | ||
log.InitGlobalLogger(configs.Logger) | ||
|
||
// starting botEngine. | ||
botEngine, err := engine.NewBotEngine(configs) | ||
pCmd.ExitOnError(cmd, err) | ||
|
||
discordMainBot, err := discord.NewDiscordBot(botEngine, configs.DiscordMainBot, config.TargetMaskMain) | ||
pCmd.ExitOnError(cmd, err) | ||
|
||
err = discordMainBot.Start() | ||
pCmd.ExitOnError(cmd, err) | ||
|
||
sigChan := make(chan os.Signal, 1) | ||
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) | ||
<-sigChan | ||
|
||
if err := discordMainBot.Stop(); err != nil { | ||
pCmd.ExitOnError(cmd, err) | ||
} | ||
|
||
botEngine.Stop() | ||
} | ||
} |
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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,21 @@ | ||
package main | ||
|
||
import ( | ||
pagu "github.com/pagu-project/Pagu" | ||
"github.com/pagu-project/Pagu/cmd" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var configPath string | ||
|
||
func main() { | ||
rootCmd := &cobra.Command{ | ||
Use: "pagu-discord", | ||
Version: pagu.StringVersion(), | ||
} | ||
|
||
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "./config.yml", "config path ./config.yml") | ||
runCommand(rootCmd) | ||
err := rootCmd.Execute() | ||
cmd.ExitOnError(rootCmd, err) | ||
} |
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,21 @@ | ||
package main | ||
|
||
import ( | ||
pagu "github.com/pagu-project/Pagu" | ||
"github.com/pagu-project/Pagu/cmd" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var configPath string | ||
|
||
func main() { | ||
rootCmd := &cobra.Command{ | ||
Use: "pagu-discord", | ||
Version: pagu.StringVersion(), | ||
} | ||
|
||
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "./config.yml", "config path ./config.yml") | ||
runCommand(rootCmd) | ||
err := rootCmd.Execute() | ||
cmd.ExitOnError(rootCmd, err) | ||
} |
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,54 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
|
||
"github.com/pagu-project/Pagu/internal/engine" | ||
|
||
"github.com/pagu-project/Pagu/internal/platforms/discord" | ||
"github.com/pagu-project/Pagu/pkg/log" | ||
|
||
pCmd "github.com/pagu-project/Pagu/cmd" | ||
"github.com/pagu-project/Pagu/config" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func runCommand(parentCmd *cobra.Command) { | ||
run := &cobra.Command{ | ||
Use: "run", | ||
Short: "Runs a testnet instance of Pagu for Discord", | ||
} | ||
|
||
parentCmd.AddCommand(run) | ||
|
||
run.Run = func(cmd *cobra.Command, _ []string) { | ||
// load configuration. | ||
configs, err := config.Load(configPath) | ||
pCmd.ExitOnError(cmd, err) | ||
|
||
// Initialize global logger. | ||
log.InitGlobalLogger(configs.Logger) | ||
|
||
// starting botEngine. | ||
botEngine, err := engine.NewBotEngine(configs) | ||
pCmd.ExitOnError(cmd, err) | ||
|
||
discordTestBot, err := discord.NewDiscordBot(botEngine, configs.DiscordTestBot, config.TargetMaskTest) | ||
pCmd.ExitOnError(cmd, err) | ||
|
||
err = discordTestBot.Start() | ||
pCmd.ExitOnError(cmd, err) | ||
|
||
sigChan := make(chan os.Signal, 1) | ||
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) | ||
<-sigChan | ||
|
||
if err := discordTestBot.Stop(); err != nil { | ||
pCmd.ExitOnError(cmd, err) | ||
} | ||
|
||
botEngine.Stop() | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
package config | ||
|
||
var ( | ||
TargetMaskMain = 1 | ||
TargetMaskTest = 2 | ||
TargetMaskModerator = 4 | ||
|
||
TargetMaskAll = TargetMaskMain | TargetMaskTest | TargetMaskModerator | ||
) | ||
|
||
const ( | ||
PriceCacheKey = "PriceCacheKey" | ||
) | ||
|
||
var HelpCommandTemplate string = `<table>{{range .}}<tr><td>{{ .Name }}</td><td>{{ .Desc }}</td></tr>{{end}}</table>` |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.