]> Cypherpunks repositories - dsc.git/commitdiff
Ability to export part of configuration
authorSergey Matveev <stargrave@stargrave.org>
Fri, 3 Oct 2025 17:37:09 +0000 (20:37 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 3 Oct 2025 18:13:09 +0000 (21:13 +0300)
dsc

diff --git a/dsc b/dsc
index 837942ba3c2e0c0c9511be721afb92c597f2e78b8bd0d0d56a99335b47fea072..4cb72f89ff5d5e0f87d599a87de328555018a940b32985dac2a72da5f83d6262 100755 (executable)
--- a/dsc
+++ b/dsc
@@ -28,8 +28,8 @@ if {$argc == 0} {
     dsc diff [prefix] -- show the difference between saved and stash
     dsc revert opt    -- revert opt's configuration
     dsc commit        -- commit (save) configuration
-    dsc export >file.txtar -- export whole configuration
-    dsc import <file.txtar -- import it
+    dsc export [prefix] >file.txtar -- export (whole by default) configuration
+    dsc import          <file.txtar -- import it
 
 Environmental variables:
     $DSC_SCHEMA -- path to the schema definition
@@ -50,6 +50,7 @@ if {[catch {set Saved $env(DSC_SAVED)}]} {set Saved saved}
 
 proc walk {root typ} {
     set rv [list]
+    set root [string trimright $root /]
     set dirs [glob -directory $root -types $typ -tails -nocomplain -- *]
     foreach s [lsort $dirs] {
         lappend rv $root/$s
@@ -241,7 +242,10 @@ switch [lindex $argv 0] {
         file delete -force $Saved.bak
     }
     export {
-        set dirs [walk $Saved d]
+        set dirs [walk $Saved/$opt d]
+        if {$opt != ""} {
+            set dirs [list $Saved/$opt {*}$dirs]
+        }
         puts "-- .dirs --"
         foreach fn $dirs {
             puts [string range $fn [string length $Saved]+1 end]