Configuration and profiles

Create and reuse profiles, try temporary overrides, and compare saved merges with replacement.

Save a repeatable selection

A profile is a named set of bundling options, not a copy of project files. Use it when you repeatedly share the same subset. This walkthrough creates a review profile, applies a temporary override, edits saved settings, and compares merging with replacement.

In a new folder named demo, create the following files with a text editor. The text after each filename is its content; use a line break for each ↵. Use sample values only. Open a terminal in demo. Do not reuse a folder containing an existing .onesourcerc.

  • README.md: # Demo
  • src/main.rs: fn main() {}
  • tests/smoke.rs: #[test] ↵ fn smoke() {}

OneSource must already be available as onesource. If it is not, follow Installation. All commands on this page start in this folder unless a step explicitly says otherwise.

The folder must start without .onesourcerc. Only this page’s profile steps create it. Profile commands manage configuration; they do not create a bundle.

1. Create, inspect and apply a profile

Create review with source-only content and a size limit. The name follows create; the options that follow it are the settings to store. --desc helps you recognize its purpose later.

Command
onesource profile create review -i "src/**" -m 100 --desc "Source review"

Expect Created profile. The command creates demo/.onesourcerc and no bundle. To inspect precisely what was stored, request JSON:

Command
onesource profile show review --json

Expected output / excerpt
{
  "description": "Source review",
  "include": "src/**",
  "max_size": 100
}

No output_path or no_tree was stored because you did not specify them. --json requests machine-readable output; without it, show groups settings and labels absent fields as unset. List names and descriptions when you need to choose a profile:

Command
onesource profile list

Expect review with its description. Apply it to a preview using -p, the short form of --profile:

Command
onesource -p review --dry-run

Expect only src/main.rs as content. The 100 KiB limit and source filter come from review; dry-run applies only to this execution. To write that selection, use onesource -p review. A named profile does not inherit a profile called default.

2. Override for one execution without saving

You may need tests as well for one review. A CLI include replaces the saved include for this run; it does not add to it:

Command
onesource -p review -i "src/**,tests/**" --dry-run

Expect src/main.rs and tests/smoke.rs, while max-size remains 100. Check the saved profile again:

Command
onesource profile show review --json

It still says "include": "src/**". This is how you experiment without changing future runs. To ignore configuration altogether, use --no-config; it skips loading even if -p was supplied. An explicit --include="" removes the include restriction for a run, and --no-tree=false overrides a saved true boolean.

3. Update settings or save a tested command

To change a profile without bundling, use update. Only specified fields change; this is a merge:

Command
onesource profile update review -x "tests/" --no-tree

Show review again. It should retain description, include and max_size, while adding exclude and no_tree:

Expected output / excerpt
{
  "description": "Source review",
  "include": "src/**",
  "exclude": "tests/",
  "no_tree": true,
  "max_size": 100
}

Alternatively, after testing a command you can save its explicit settings into the active profile. Here, make README part of future reviews and turn the tree back on:

Command
onesource -p review -i "src/**,README.md" --no-tree=false --save --dry-run

Expect a Saved profile message, a tree, and README.md plus src/main.rs as content. show review should now have include="src/**,README.md" and no_tree=false; the existing exclude and max_size remain. Only explicitly supplied persistable options are saved, not dry-run or -p. Dry-run does not prevent configuration writes when --save is present. Save happens before scanning, so a scan failure does not undo it.

To establish defaults for runs without -p, save to the implicit default profile:

Command
onesource --no-config -i "src/**" --save --dry-run

This creates or merges default. It does not alter review. For a new named profile, prefer create; --no-config -p NAME --save also allows creation, while requesting a missing named profile with loading enabled fails before saving.

4. Replace instead of merging

Use replacement when the old fields should be removed. Start from the profile edited above, then replace it with only a README include:

Command
onesource profile update review --replace -i "README.md"

Command
onesource profile show review --json

Expected output / excerpt
{
  "include": "README.md"
}

Description, exclude, no_tree and max_size are gone. Unset values now resolve to defaults, so the limit is back to 500 KiB and the tree is enabled. Run onesource -p review --dry-run to verify README alone is attached.

Normal bundling also supports --save --replace. To replace review without loading old fields into this run, use:

Command
onesource --no-config -p review --save --replace -i "src/**" --dry-run

Expect the stored profile to contain only include="src/**" and the preview to process main.rs. Without --no-config, the current run may still use loaded old fields even though replacement removes them from disk. --replace requires --save in normal runs; profile update --replace does not.

5. Rename, describe or remove a profile

Give review a clearer name after the replacement step:

Command
onesource profile rename review backend

list should now show backend, not review. To give it a new description without changing selection:

Command
onesource profile update backend --desc "Backend source"

show backend should contain include plus description. Once the profile is no longer needed, delete it:

Command
onesource profile delete backend

list no longer includes backend. Deleting a profile removes settings, not source files or bundles. Deleting default makes unnamed runs return to built-in settings. create fails on duplicate names; rename fails if the destination exists; show/update/delete fail when their named profile is missing. Names must be nonempty ASCII letters/digits, dots, underscores or hyphens.

Understand the saved JSON and precedence

Open .onesourcerc in a text editor only after checking the saved profile. The top-level profiles object maps names to option objects. JSON uses underscores (output_path); CLI uses hyphens (--output-path). The description field corresponds to --desc. To configure by hand, save valid JSON and verify it with profile show before bundling. Here is a complete field example, separate from the walkthrough’s evolving profile:

JSON lives at scan-root/.onesourcerc. Explicit CLI values win over the selected profile, then built-in defaults apply. The default profile is optional; named profiles do not inherit it. Unknown fields are ignored by serde. Omitted or null fields use defaults/inheritance; empty strings and false are explicit values. Field types, defaults and effects are listed in CLI reference. Only the fields below are persisted; path, profile choice, copy, dry_run, save, replace, no_config and show_arg are not persisted.

Configuration example (JSON)
{
  "profiles": {
    "default": {
      "description": "Source review",
      "output_path": "review.onesource",
      "include": "src/**",
      "exclude": "src/legacy/",
      "tree_include": "",
      "tree_exclude": "target/",
      "max_size": 500,
      "no_ignore": false,
      "tree_no_ignore": false,
      "no_tree": false,
      "no_blacklist": false
    }
  }
}

A supplied CLI value wins over the chosen profile, then built-in defaults apply. default is used only when no -p is provided, not as an inheritance base. Configuration is read from the scan root; to manage another folder use onesource /path/to/project profile list. Management commands still read configuration even with a top-level --no-config. Avoid concurrent manual edits: configuration writes are direct, not atomic.

Legacy aliases and recovery

For existing scripts, profile ls is an alias for list and profile rm NAME is an alias for delete. The hidden legacy description command requires -p:

Command
onesource profile desc "Backend source" -p default

This requires an existing default profile and merges its description; new scripts should use profile update default --desc "Backend source". list/show support the boolean flag --json (default false). create/update accept the persistable options from CLI reference; update --replace is a boolean action flag, default false. Each subcommand has --help.

If configuration is malformed or uses a flat old format, back it up and follow configuration migration. --no-config bypasses normal loading but does not bypass the config read required for --save. To clear an include without deleting the field use --include=""; to remove fields entirely, replace the profile or edit JSON.