license

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package license provides CLI-level license key management operations: setting, reading, clearing, and displaying license keys.

Key storage: ~/.config/nself/license.json (chmod 0600) Legacy storage (v1): ~/.nself/license.json Env override: NSELF_PLUGIN_LICENSE_KEY

Index

Constants

View Source
const LicenseDirV1 = ".nself"

LicenseDirV1 is the v1 license directory name under $HOME.

View Source
const LicenseDirV2 = ".config/nself"

LicenseDirV2 is the v2 license directory name under $HOME.

View Source
const LicenseFile = "license.json"

LicenseFile is the license JSON filename used in both v1 and v2.

Variables

This section is empty.

Functions

func ClearKey

func ClearKey() error

ClearKey removes both the stored license key file and the validation cache file from ~/.nself/license/.

func GetKey

func GetKey() (string, error)

GetKey returns the current license key. It checks the NSELF_PLUGIN_LICENSE_KEY environment variable first, then falls back to reading ~/.nself/license/key. Returns ("", nil) when no key is configured.

func MigrateLicenseFromV1

func MigrateLicenseFromV1(home string) error

MigrateLicenseFromV1 copies ~/.nself/license.json to ~/.config/nself/license.json when upgrading from v1. The function is a no-op when:

  • v2 already exists (NEVER overwrite existing v2 license)
  • v1 does not exist (nothing to migrate)

On success the v1 file is preserved (non-destructive). File is written with mode 0600 matching the key file convention.

func SetKey

func SetKey(key string) error

SetKey validates the key format, creates the license directory if needed, and writes the key to ~/.nself/license/key with mode 0600.

func ShowKey

func ShowKey() (masked string, tier string, err error)

ShowKey returns a masked version of the current key and its detected tier. The masked key shows the first 10 and last 4 characters with the middle replaced by asterisks. If no key is set, all return values are empty strings with a nil error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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