cliargs

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: GPL-3.0 Imports: 5 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

Overview

Package cliargs prepares the command line of nps and npc for pflag. A service keeps the arguments it was installed with, so an update must not stop because an argument was renamed or removed since: an argument of an earlier version is translated to what replaces it or dropped with a warning (the Rules NPC and NPS), and any other unknown argument is dropped with a warning, rather than failing the start.

Index

Constants

This section is empty.

Variables

View Source
var NPC = []Rule{

	{Name: "tls_enable", Bool: true, Translate: func(value string, hasValue bool) ([]string, string) {
		on := true
		if hasValue {
			var err error
			if on, err = strconv.ParseBool(value); err != nil {
				return nil, "not a boolean, ignored"
			}
		}
		if !on {
			return nil, "old flag, ignored; it has no effect when false"
		}
		return []string{"--type=tls"}, "old spelling of -type=tls, used as -type=tls"
	}},
	ignore("new_protocol", true, "ignored: the core protocol is the only one npc speaks"),
	ignore("proto_version", false, "ignored: npc only speaks the latest protocol; if the server is older, update the server first"),
	ignore("stun_addr", false, "ignored: it no longer has an effect; STUN servers are now set on the server (p2p_stun_servers in nps.conf)"),
	ignore("p2p_type", false, "ignored: it no longer has an effect; P2P picks its transport itself"),
	ignore("log_color", false, "ignored: log lines are plain logfmt or JSON (-log_format)"),
	ignore("log_daily", false, "ignored: it no longer has an effect; logs rotate by -log_max_size and -log_max_days"),
}

NPC are the npc flags of earlier versions (0.26 to 0.34) that npc no longer defines.

View Source
var NPS []Rule

NPS are the nps flags of earlier versions that nps no longer defines.

Functions

func NPCLocal

func NPCLocal(args []string) (out, warnings []string)

NPCLocal translates the point-to-point access flags of earlier versions in args (before Prepare): -local_type=p2p|p2ps|p2pt|secret, -target_type, -fallback_secret and -disable_p2p become -local_type and -conn_mode, combined as config.LegacyLocal does for npc.conf. Other arguments stay as they are. Remove in the next major version.

func Prepare

func Prepare(fs *pflag.FlagSet, args []string, rules []Rule, commands ...string) (out, warnings []string)

Prepare returns args, without the program name, ready for fs.Parse, and the warnings to log once logging is set up: single-dash long flags such as -server become --server; a single-dash -name=value of a known flag is joined with the arguments after it that start with ".", which PowerShell split off at the first '.' of the value; a flag fs does not define is handled by its rule in rules or else left out. A flag left out that is not Bool and is written without "=" also takes the argument after it, its value, unless that starts with "-" or is one of commands. Arguments after "--" are kept as they are.

Types

type Rule

type Rule struct {
	// Name is the flag name as earlier versions spelt it, without dashes.
	Name string
	// Bool marks a boolean flag: it never takes the argument after it as
	// its value, as -name, -name=true and -name=false.
	Bool bool
	// Translate returns the arguments that replace the flag given value
	// ("" when none was given), and the warning to log about it. They are
	// placed after the other flags, so they win over what those set, as
	// earlier versions let the old flag win.
	Translate func(value string, hasValue bool) (args []string, warning string)
}

A Rule says what an argument of an earlier version becomes.

Jump to

Keyboard shortcuts

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