reset.rs

crates/veilvoice-cli/src/reset.rs

veilvoice-cli · 431 lines · read the source here · or on GitHub

veilvoice reset: putting this machine back to a new install.

Why it is here as well as in the window

A policy or a mandate set from the command line has to be removable from the command line. Somebody who fixed a machine with veilvoice policy should not have to open a window to undo it, and a machine that has no display -- a server, a container, somebody's headless box -- has no window to open.

The deciding and the removing are veilvoice_crypto::reset's, so this and the window remove the same things, in the same order, and describe them in the same words. This module is the part that prints, asks and counts.

Nothing is removed until it has been read

The plan is printed first, every time, with a line per thing and the size of it. Then:

  • --dry-run prints and stops. The default for somebody who wants to look.
  • --yes is enough where nothing in the plan is irreplaceable.
  • Where something is, the word RESET has to be typed, exactly as veilvoice shred asks for DESTROY. --yes is deliberately not accepted in its place: a flag is what somebody leaves in a script and forgets, and this is the one command where forgetting costs recordings.
  • --confirm RESET is that typed word, for a machine with nothing to type into. A server being rebuilt has no terminal and still has to be resettable. It is a separate flag carrying the word itself rather than a second meaning for --yes, so it cannot be arrived at by copying the flags off another command.

In plain words

Puts VeilVoice back to how it was the day you installed it. It shows you what it is about to remove before it removes anything, and it leaves your password and the key to your recordings alone unless you ask for those too with --drop-keys.

WHAT THIS FILE CONTAINS

431 lines defining 6 functions (1 public), 0 types and 1 constant. Everything below is read out of the source, so it cannot disagree with the code.

What happens when it runs. These are the ways in: public, and nothing else in this file calls them, so they are what an outside caller reaches first.

  • run line 56 · Run the reset.
    reaches agreed, describe, report_kept, count, size

WHAT CALLS WHAT

run line 56 describe line 136 report_kept line 187 agreed line 213 count line 279 size line 292 entry: a way in: public, and nothing in this file calls it helper: private to this file dashed: a call that goes back up, or across a wrapped rank The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one.

The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one.

The same graph as Mermaid source
%%{init: {"theme":"base","themeVariables":{"background":"#1a1b26","primaryColor":"#1f2335","primaryTextColor":"#c0caf5","primaryBorderColor":"#7aa2f7","secondaryColor":"#16161e","tertiaryColor":"#16161e","lineColor":"#737aa2","textColor":"#c0caf5","mainBkg":"#1f2335","nodeBorder":"#7aa2f7","clusterBkg":"#16161e","clusterBorder":"#2f3549","fontFamily":"ui-monospace, SFMono-Regular, Consolas, monospace","fontSize":"14px"}}}%%
flowchart TD
    n_run(["run<br/>line 56"])
    n_describe["describe<br/>line 136"]
    n_report_kept["report_kept<br/>line 187"]
    n_agreed["agreed<br/>line 213"]
    n_count["count<br/>line 279"]
    n_size["size<br/>line 292"]
    n_describe --> n_count
    n_describe --> n_report_kept
    n_describe --> n_size
    n_run --> n_agreed
    n_run --> n_describe
    n_run --> n_report_kept
    click n_run href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-cli/src/reset.rs#L56" "open the source"
    click n_describe href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-cli/src/reset.rs#L136" "open the source"
    click n_report_kept href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-cli/src/reset.rs#L187" "open the source"
    click n_agreed href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-cli/src/reset.rs#L213" "open the source"
    click n_count href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-cli/src/reset.rs#L279" "open the source"
    click n_size href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-cli/src/reset.rs#L292" "open the source"
    classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
    class n_run entry
    classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
    class n_describe,n_report_kept,n_agreed,n_count,n_size helper
    subgraph chart_key ["Key"]
        direction LR
        key_entry["entry: a way in: public, and nothing in this file calls it"]
        key_helper["helper: private to this file"]
    end
    class key_entry entry
    class key_helper helper

This site loads no third-party script, so it cannot run Mermaid; the diagram above is the same nodes and edges drawn by the generator instead. GitHub renders the source below directly.

ITEMS

ItemLineDocumentation
TYPED pub const47The word somebody types where the plan cannot be undone.
run pub fn56Run the reset.
describe fn136Print the plan: a line per thing, and what it adds up to.
report_kept fn187Print what stays, when anything does.
agreed fn213Whether to go ahead: a flag where that is enough, a typed word where it is not.
count fn279"one file" or "nine files".
size fn292A size somebody can judge at a glance.