commands

package
v0.0.0-...-828d3b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FunctionSignatureCmd = &cobra.Command{
	Use:    "function_signature",
	Short:  "load solid function signature",
	Hidden: true,
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		err = entity.Start(logger.With("lib", "ent"), config)
		if err != nil {
			return
		}

		err = memo.Start(logger.With("lib", "memo"), config)
		if err != nil {
			return
		}
		service.ScanSignature(cmd.Context())
		return nil
	},
}
View Source
var MigrateCmd = &cobra.Command{
	Use:   "migrate",
	Short: "Automatic Migration",
	RunE: func(cmd *cobra.Command, args []string) error {

		err := entity.Start(logger.With("lib", "ent"), config)
		if err != nil {
			return err
		}
		db, err := entity.Client(cmd.Context())
		if err != nil {
			return err
		}
		err = db.Debug().Schema.Create(cmd.Context())
		if err != nil {
			return err
		}
		return nil
	},
}
View Source
var RootCmd = &cobra.Command{
	Use: version.Name,
	PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
		logger.Debug("program start")
		if cmd.Name() == VersionCmd.Name() {
			return nil
		}
		config, err = ParseConfig(cmd)
		if err != nil {
			return err
		}

		if config.LogFormat == cfg.LogFormatJSON {
			logger = log.NewTMJSONLogger(log.NewSyncWriter(os.Stdout))
		}

		logger, err = cli.ParseLogLevel(config.LogLevel, logger, cfg.DefaultLogLevel)
		if err != nil {
			return err
		}

		if viper.GetBool(cli.TraceFlag) {
			logger = log.NewTracingLogger(logger)
		}

		logger = logger.With("module", "main")

		log.SetDefaultLogger(logger)
		task.SetLogger(logger)
		task.SetConfig(config)
		cmd.SetContext(
			log.WithContext(cmd.Context(), logger),
		)

		return nil
	},
}
View Source
var ScanCmd = &cobra.Command{
	Use:   "scan",
	Short: "scan block",
	Run: func(cmd *cobra.Command, args []string) {

		err := entity.Start(logger.With("lib", "ent"), config)
		if err != nil {
			return
		}

		err = memo.Start(logger.With("lib", "memo"), config)
		if err != nil {
			return
		}
		moralis.SetConfig(config)

		if config.IsLocal() {
			task.BlockScanRun(schedule.CommandContext(cmd))
		}

		task.InitTask()

		service.ScanBlock()

		task.InitEvmParse(cmd.Context(), config, logger.With("module", "task"))

		schedule.Schedule(schedule.CommandContext(cmd))

		aimos.TrapSignal(logger, func() {
			schedule.Shutdown(context.Background())
		})

		select {}
	},
}

ScanCmd ...

View Source
var VersionCmd = &cobra.Command{
	Use:   "version",
	Short: "Show version info",
	Run: func(cmd *cobra.Command, args []string) {
		aimVersion := version.Version
		if version.GitCommitHash != "" {
			aimVersion += "+" + version.GitCommitHash
		}

		if verbose {
			values, _ := json.MarshalIndent(struct {
				Version string `json:"version"`
			}{
				Version: aimVersion,
			}, "", "  ")
			fmt.Println(string(values))
		} else {
			fmt.Println(aimVersion)
		}
	},
}

VersionCmd ...

Functions

func AddFlags

func AddFlags(cmd *cobra.Command)

AddFlags exposes some common configuration options on the command-line These are exposed for convenience of commands embedding

func AddNetworkFlag

func AddNetworkFlag(cmds ...*cobra.Command)

func GetAbi

func GetAbi()

func NewExecCmd

func NewExecCmd() *cobra.Command

func NewStartCmd

func NewStartCmd() *cobra.Command

NewStartCmd returns the command that allows the CLI to start a node.

func ParseConfig

func ParseConfig(cmd *cobra.Command) (*cfg.Config, error)

ParseConfig retrieves the default environment configuration, sets up the aim root and ensures that the root exists

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL