Debian Codegraph @

cli/tools-cli/docs/merge.md

raw symbols SCIP
1 # Merge tool docs
2
3 The merge tool is an handy tool that helps to merge an old version of a spec in a new one.
4
5 ## Usage
6
7 ```sh
8 npx @withfig/autocomplete-tools@latest merge <oldspec> <newspec> [-p, --presets <name>] [--ignore-command-props <props>] [--ignore-option-props <props>] [--ignore-arg-props <props>]
9 ```
10
11 ## How it works
12
13 Basically it keeps everything from the old spec (which must be the one that has some manually added properties, generators...) and overrides the properties that are specified in the [options](#further-customization) or in the [preset](#presets).
14
15 ## Presets
16
17 We provide some presets to be used along with our [integrations](https://fig.io/docs/guides/autocomplete-for-teams#next-steps).
18
19 For example if you regenerated a spec after an update to your CLI structure you can easily pass the `--preset <name>` option to the merge tool
20 and it will merge the two specs like magic keeping the options you customized in the old one but also adding, removing and updating everything new.
21 ```
22 npx @withfig/autocomplete-tools@latest merge old-spec.ts new-spec.ts --preset commander
23 ```
24 > See a live example directly in this repo [package.json](https://github.com/withfig/autocomplete-tools/blob/262cc31134e95e50ee546c67d343ea6661e17592/packages/autocomplete-tools/package.json#L11).
25
26 ## Further customization
27
28 If you are not using any of our integrations because you built some custom generator for your specs,
29 then you can customize how the merge tool behaves through some options:
30 - `--ignore-command-props <props>`: the **command** props that should always be overridden
31 - `--ignore-option-props <props>`: the **option** props that should always be overridden
32 - `--ignore-arg-props <props>`: the **arg** props that should always be overridden
33
34 There is also another option that allows to specify some kind of props that should always be overridden in each of the contexts specified above:
35 - `-i, --ignore-props <props>`: the props that should always be overridden
36
37 ### How all these options will help me?
38
39 Well, if you built a custom spec generation tool you are probably generating only some of the several props
40 that Fig's Autocomplete allows you to add to a spec,
41 and maybe you are adding some props manually after the generation.
42
43 With the options mentioned above you can tell the merge tool which are the properties that you are autogenerating
44 so that it keeps those always updated while still maintaining your manual edits.
45
46 ### Example
47
48 Your custom generation tool creates specs that only contain subcommand `name` and `description`, no args and no options.
49 The resulting spec may look something like this:
50 ```ts
51 /* new spec autogenerated */
52 const completionSpec: Fig.Spec = {
53 name: "my-cli",
54 description: "Some description",
55 subcommands: [{
56 name: "my-cli-subcommand",
57 description: "Some subcommand description"
58 }]
59 // missing options and args that have probably been manually added in the old spec
60 }
61 ```
62
63 So you will call the merge tool with the following options:
64 ```sh
65 npx @withfig/autocomplete-tools@latest merge <oldspec> <newspec> --ignore-command-props=name,description,subcommands
66 ```
67 > **NOTE**: we are explicitly adding `subcommands` prop to the command ignored props.