cli

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	API *pcloud.API
)
View Source
var (
	// FileCmd declares the sub-command group file
	FileCmd = &cobra.Command{
		Use:   "file",
		Short: "Actions to manage files.",
		Long: `All commands related to mangage files.
This includes rename file, upload file, download file, etc.`,

		Run: func(cmd *cobra.Command, args []string) {

		},
	}
)
View Source
var (
	// FolderCmd declares the sub-command group folder
	FolderCmd = &cobra.Command{
		Use:   "folder",
		Short: "Actions to manage folders.",
		Long: `All commands related to mangage folders.
This includes rename folder, create folder, delete folder, etc.`,

		Run: func(cmd *cobra.Command, args []string) {

		},
	}
)
View Source
var RootCmd = &cobra.Command{
	Use:   "pcloud-cli",
	Short: "pcloud-cli is a command line interface to the pCloud API.",
	Long: `A command line interface to interact with pCloud storage.
More info can be found on github, http://github.com/saintedlama/pcloud-cli`,
	Run: func(cmd *cobra.Command, args []string) {
		if !API.IsConfigured() {
			fmt.Println("No configuration found. Starting onboarding...")
			fmt.Println()
			onboard(cmd, args)
			return
		}

		info, err := API.GetUserInfo()
		if err != nil {
			fmt.Println("Could not fetch account info:", err)
			cmd.Help()
			return
		}

		planLabel := "Free"
		switch {
		case info.PremiumLifetime:
			planLabel = "Premium Lifetime"
		case info.Premium:
			planLabel = "Premium"
		}

		usedPct := float64(info.UsedQuota) / float64(info.Quota) * 100

		labelSt := lipgloss.NewStyle().Foreground(lipgloss.Color("8"))
		valueSt := lipgloss.NewStyle().Foreground(lipgloss.Color("6")).Bold(true)

		var storageSt lipgloss.Style
		switch {
		case usedPct >= 90:
			storageSt = lipgloss.NewStyle().Foreground(lipgloss.Color("1")).Bold(true)
		case usedPct >= 70:
			storageSt = lipgloss.NewStyle().Foreground(lipgloss.Color("3")).Bold(true)
		default:
			storageSt = lipgloss.NewStyle().Foreground(lipgloss.Color("2")).Bold(true)
		}

		fmt.Println(labelSt.Render("User Information"))
		fmt.Println(labelSt.Render("Account:  ") + valueSt.Render(info.Email))
		fmt.Println(labelSt.Render("Plan:     ") + valueSt.Render(planLabel))
		fmt.Println(labelSt.Render("Storage:  ") +
			storageSt.Render(fmt.Sprintf("%s / %s", formatBytes(info.UsedQuota), formatBytes(info.Quota))) +
			labelSt.Render(fmt.Sprintf(" (%.1f%% used)", usedPct)))
		fmt.Println()
		cmd.Help()
	},
}

RootCmd declares the main command

View Source
var SyncCmd = &cobra.Command{
	Use:   "sync <pcloud-path> [local-dir]",
	Short: "Sync a pCloud folder to a local directory.",
	Long: `Download all files from a pCloud path to a local directory.

Only files that are newer on pCloud are downloaded. Files that have been
deleted from pCloud are removed from the local directory.

If local-dir is omitted, the last path component of the pCloud path is used
as the destination directory relative to the current working directory.`,
	Args: cobra.RangeArgs(1, 2),
	Run:  runSyncOnce,
}

SyncCmd is the top-level "sync" command that performs a single sync pass.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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