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 ¶
const LicenseDirV1 = ".nself"
LicenseDirV1 is the v1 license directory name under $HOME.
const LicenseDirV2 = ".config/nself"
LicenseDirV2 is the v2 license directory name under $HOME.
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 ¶
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 ¶
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 ¶
SetKey validates the key format, creates the license directory if needed, and writes the key to ~/.nself/license/key with mode 0600.
Types ¶
This section is empty.