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 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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