Documentation
¶
Overview ¶
Package setup implements the interactive `initialize` subcommand: language, API credentials, Telegram login and optional system service registration.
Index ¶
- Variables
- func Initialize(ctx context.Context, opt Options) error
- func Login(ctx context.Context, u *UI, client *telegram.Client, ...) (*tg.User, error)
- type ClientFactory
- type Options
- type Service
- type UI
- func (u *UI) Ask(label, def string, valid func(string) bool, invalidKey string) (string, error)
- func (u *UI) AskMasked(label, def string, valid func(string) bool, invalidKey string) (string, error)
- func (u *UI) Blank()
- func (u *UI) Choose(options []string, def int, invalid string) (int, error)
- func (u *UI) Cmd(s string) string
- func (u *UI) Confirm(label string, def bool) (bool, error)
- func (u *UI) Err(s string)
- func (u *UI) Hint(s string)
- func (u *UI) OK(s string)
- func (u *UI) Secret(label string) (string, error)
- func (u *UI) Step(n, total int, key string)
- func (u *UI) T(key string, args ...any) string
- func (u *UI) Title(s string)
- func (u *UI) Warn(s string)
Constants ¶
This section is empty.
Variables ¶
var ErrAborted = errors.New("aborted")
ErrAborted is returned when stdin closes mid-prompt.
Functions ¶
func Initialize ¶
Initialize runs the interactive setup in the data home.
Types ¶
type ClientFactory ¶
ClientFactory builds the Telegram client for a config. main passes the app's constructor so login uses the same device info and session file.
type Options ¶
type Options struct {
Home string // data home, already resolved
Command string // registered shell command name
NewClient ClientFactory
// NewBotClient builds the companion bot client for a config.
NewBotClient ClientFactory
}
Options configures Initialize.
type Service ¶
type Service struct {
Name string // unit name without .service
Binary string // absolute path of the papervalet binary
Home string // PAPERVALET_HOME
Command string // PAPERVALET_CMD, for hints printed by the bot
User bool // user unit (~/.config/systemd/user) instead of system unit
}
Service describes a systemd unit running one PaperValet instance.
type UI ¶
UI is a small line-oriented terminal prompter. All text goes through the setup catalog in the language picked at the start.
func (*UI) AskMasked ¶
func (u *UI) AskMasked(label, def string, valid func(string) bool, invalidKey string) (string, error)
AskMasked is Ask but shows a masked form of def in the prompt.
func (*UI) Choose ¶
Choose shows a numbered list and returns the picked index. invalid is shown on bad input; it is passed in because the language may not be chosen yet.