account

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CurrentCmd = &cobra.Command{
	Use:   "current",
	Short: "Show the current account",
	RunE: func(cmd *cobra.Command, _ []string) error {
		ctx := cmd.Context()

		r8, err := client.NewClient()
		if err != nil {
			return err
		}

		account, err := r8.GetCurrentAccount(ctx)
		if err != nil {
			return fmt.Errorf("failed to get account: %w", err)
		}

		if cmd.Flags().Changed("web") {
			if util.IsTTY() {
				fmt.Println("Opening in browser...")
			}

			url := "https://replicate.com/" + account.Username
			err := browser.OpenURL(url)
			if err != nil {
				return fmt.Errorf("failed to open browser: %w", err)
			}

			return nil
		}

		if cmd.Flags().Changed("json") || !util.IsTTY() {
			bytes, err := json.MarshalIndent(account, "", "  ")
			if err != nil {
				return fmt.Errorf("failed to marshal account: %w", err)
			}
			fmt.Println(string(bytes))
			return nil
		}

		fmt.Printf("Type: %s\n", account.Type)
		fmt.Printf("Username: %s\n", account.Username)
		fmt.Printf("Name: %s\n", account.Name)
		fmt.Printf("GitHub URL: %s\n", account.GithubURL)

		return nil
	},
}

CurrentCmd represents the get current account command

View Source
var RootCmd = &cobra.Command{
	Use:     "account [subcommand]",
	Short:   "Interact with accounts",
	Aliases: []string{"accounts", "a"},
}

Functions

func AddCurrentAccountFlags

func AddCurrentAccountFlags(cmd *cobra.Command)

Types

This section is empty.

Jump to

Keyboard shortcuts

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