features_02-scope.md.bdd8e6d2.js
1 import{_ as e,y as o,x as n,W as s}from"./plugin-vue_export-helper.f07d1dea.js";const f='{"title":"Priority Resolving","description":"","frontmatter":{},"headers":[{"level":2,"title":"Background","slug":"background"},{"level":2,"title":"Scope","slug":"scope"}],"relativePath":"features/02-scope.md","lastUpdated":1692639959838}',a={},t=s(`<h1 id="priority-resolving-examples" tabindex="-1">Priority Resolving <sub>[<a href="/config/guide/05-priority.html"><strong>Examples</strong></a>]</sub> <a class="header-anchor" href="#priority-resolving-examples" aria-hidden="true">#</a></h1><h2 id="background" tabindex="-1">Background <a class="header-anchor" href="#background" aria-hidden="true">#</a></h2><p>Since <code>dt-cli</code> syncs your dotfiles on a per-group basis, you don't want to run through all of the groups when only a single file is modified in your dotfile library. For example, when you updated your shell init script, you might run the following command:</p><div class="language-shell"><pre><code>$ dt-cli shell 2 INFO dt_core::syncing <span class="token operator">></span> Local group: <span class="token punctuation">[</span>shell<span class="token punctuation">]</span> 3 </code></pre></div><p>Nevertheless, sometimes you have to run a full sync, which involves all of your defined groups in your config file. It may look like this:</p><div class="language-shell"><pre><code>$ dt-cli 4 INFO dt_core::syncing <span class="token operator">></span> Local group: <span class="token punctuation">[</span>gdb<span class="token punctuation">]</span> 5 INFO dt_core::syncing <span class="token operator">></span> Local group: <span class="token punctuation">[</span>ssh<span class="token punctuation">]</span> 6 INFO dt_core::syncing <span class="token operator">></span> Local group: <span class="token punctuation">[</span>gpg<span class="token punctuation">]</span> 7 INFO dt_core::syncing <span class="token operator">></span> Local group: <span class="token punctuation">[</span>systemd<span class="token punctuation">]</span> 8 INFO dt_core::syncing <span class="token operator">></span> Local group: <span class="token punctuation">[</span>dt<span class="token punctuation">]</span> 9 INFO dt_core::syncing <span class="token operator">></span> Local group: <span class="token punctuation">[</span>nvim<span class="token punctuation">]</span> 10 INFO dt_core::syncing <span class="token operator">></span> Local group: <span class="token punctuation">[</span>fontconfig<span class="token punctuation">]</span> 11 INFO dt_core::syncing <span class="token operator">></span> Local group: <span class="token punctuation">[</span>shell<span class="token punctuation">]</span> 12 INFO dt_core::syncing <span class="token operator">></span> Local group: <span class="token punctuation">[</span>gui<span class="token punctuation">]</span> 13 INFO dt_core::syncing <span class="token operator">></span> Local group: <span class="token punctuation">[</span>xdg_config_home<span class="token punctuation">]</span> 14 INFO dt_core::syncing <span class="token operator">></span> Local group: <span class="token punctuation">[</span>misc<span class="token punctuation">]</span> 15 </code></pre></div><p>Some groups may contain overlapping source items, in the above example, group <code>xdg_config_home</code> contains <code>fontconfig</code> and <code>dt</code>'s base directories. It's neither friendly nor efficient for <code>dt-cli</code> to sync the same item twice or even more times: it's slow, and the final result depends on the order of the definitions of the groups.</p><h2 id="scope" tabindex="-1">Scope <a class="header-anchor" href="#scope" aria-hidden="true">#</a></h2><p><code>dt-cli</code> solves this problem by defining an extra attribute <code>scope</code> for each group.</p><p>A group's <a href="/config/key-references.html#scope"><code>scope</code></a> decides the priority of it being synced. There are 3 predefined scopes, namely <code>Dropin</code>, <code>App</code> and <code>General</code>. The names are pretty much self-explanatory:</p><ul><li><code>General</code> groups have the <strong>lowest</strong> priority. They are typically meant for the parent directories of your dotfile library.</li><li><code>Dropin</code> groups have the <strong>highest</strong> priority. They are typically meant for those items that come from external sources as drop-in replacements, such as files from a system directory that is managed by your system's package manager.</li><li><code>App</code> groups have medium priority. As the name implies, it is meant for some specific application, for example, a group containing your config files for GUI applications, or a group containing your shell/editor preferences/init scripts, etc..</li></ul><div class="info custom-block"><p class="custom-block-title">INFO</p><p>A <code>scope</code> key in a group's definition is optional. When omitted, the default value is <code>General</code>.</p></div><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>Generally, a larger scope has a lower priority.</p></div><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>If a file is included in multiple groups that have the same <code>scope</code>, it will only be synced by the first group appeared in your config file, later defined groups (with the same <code>scope</code>) won't repeatedly sync the file.</p></div>`,14),c=[t];function p(i,r,l,d,u,g){return n(),o("div",null,c)}var y=e(a,[["render",p]]);export{f as __pageData,y as default};