XR for Universal Blue and Fedora Atomic Desktops
vr fedora-atomic linux
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow updating only applications or sysconfigs

Shiloh Fen c745baed f23c2baa

+59 -40
+59 -40
src/atomic-xr/mod.nu
··· 65 65 } 66 66 67 67 # Apply current configuration (and update applications) 68 - export def apply [] { 68 + export def apply [ 69 + --sysconfigs-only (-s) 70 + --applications-only (-a) 71 + ] { 72 + if $sysconfigs_only and $applications_only { 73 + error make { 74 + msg: "Incompatible flags" 75 + label: { 76 + text: "Incompatible with --sysconfigs-only (-s)" 77 + span: (metadata $applications_only).span 78 + } 79 + help: "Only sepecify 1 of: --sysconfigs-only (-s), --applications-only (-a)" 80 + } 81 + } 69 82 let config = try {open $config_path} catch { 70 83 error make { 71 84 msg: "Failed to open config file." ··· 73 86 } 74 87 } 75 88 76 - # HACK: `scope modules` doesn't work how you'd expect when executed from modules, so we have to do this 77 - const applications_path = path self ./applications.nu 78 - const sysconfigs_path = path self ./sysconfig.nu 79 - let sysconfig_commands = nu -c $"use ($sysconfigs_path) ; scope modules | where name == sysconfig | get 0.commands.name | to nuon" | from nuon 80 - let application_commands = nu -c $"use ($applications_path) ; scope modules | where name == applications | get 0.commands.name | to nuon" | from nuon 89 + if not $sysconfigs_only { 90 + const applications_path = path self ./applications.nu 91 + # HACK: `scope modules` doesn't work how you'd expect when executed from modules, so we have to do this 92 + let application_commands = nu -c $"use ($applications_path) ; scope modules | where name == applications | get 0.commands.name | to nuon" | from nuon 81 93 82 - let supported_applications = $application_commands 83 - | where $it starts-with "install " 84 - | str replace "install " "" 85 - | where {|e| $"uninstall ($e)" in $application_commands} 94 + let supported_applications = $application_commands 95 + | where $it starts-with "install " 96 + | str replace "install " "" 97 + | where {|e| $"uninstall ($e)" in $application_commands} 86 98 87 - log debug $"Supported applications: ($supported_applications | to text)" 99 + log debug $"Supported applications: ($supported_applications | to text)" 88 100 89 - let supported_sysconfigs = $sysconfig_commands 90 - | where $it starts-with "enable " 91 - | str replace "enable " "" 92 - | where {|e| $"disable ($e)" in $sysconfig_commands} 101 + $config.applications 102 + | each {|e| 103 + if $e not-in $supported_applications { 104 + log warning $"Unkown application `($e)` found in configuration." 105 + } 106 + } 93 107 94 - log debug $"Supported sysconfigs: ($supported_sysconfigs | to text)" 95 - 96 - $config.applications 97 - | each {|e| 98 - if $e not-in $supported_applications { 99 - log warning $"Unkown application `($e)` found in configuration." 108 + $supported_applications 109 + | each {|application| 110 + if $application in $config.applications { 111 + nu -c $"use ($applications_path) ; applications install ($application)" 112 + } else { 113 + nu -c $"use ($applications_path) ; applications uninstall ($application)" 114 + } 100 115 } 101 116 } 102 117 103 - $config.sysconfigs 104 - | each {|e| 105 - if $e not-in $supported_sysconfigs { 106 - log warning $"Unkown sysconfig `($e)` found in configuration." 107 - } 108 - } 118 + if not $applications_only { 119 + const sysconfigs_path = path self ./sysconfig.nu 120 + # HACK: `scope modules` doesn't work how you'd expect when executed from modules, so we have to do this 121 + let sysconfig_commands = nu -c $"use ($sysconfigs_path) ; scope modules | where name == sysconfig | get 0.commands.name | to nuon" | from nuon 122 + 123 + let supported_sysconfigs = $sysconfig_commands 124 + | where $it starts-with "enable " 125 + | str replace "enable " "" 126 + | where {|e| $"disable ($e)" in $sysconfig_commands} 109 127 110 - $supported_applications 111 - | each {|application| 112 - if $application in $config.applications { 113 - nu -c $"use ($applications_path) ; applications install ($application)" 114 - } else { 115 - nu -c $"use ($applications_path) ; applications uninstall ($application)" 128 + log debug $"Supported sysconfigs: ($supported_sysconfigs | to text)" 129 + 130 + $config.sysconfigs 131 + | each {|e| 132 + if $e not-in $supported_sysconfigs { 133 + log warning $"Unkown sysconfig `($e)` found in configuration." 134 + } 116 135 } 117 - } 118 136 119 - $supported_sysconfigs 120 - | each {|sysconfig| 121 - if $sysconfig in $config.sysconfigs { 122 - nu -c $"use ($sysconfigs_path) ; sysconfig enable ($sysconfig)" 123 - } else { 124 - nu -c $"use ($sysconfigs_path) ; sysconfig disable ($sysconfig)" 137 + $supported_sysconfigs 138 + | each {|sysconfig| 139 + if $sysconfig in $config.sysconfigs { 140 + nu -c $"use ($sysconfigs_path) ; sysconfig enable ($sysconfig)" 141 + } else { 142 + nu -c $"use ($sysconfigs_path) ; sysconfig disable ($sysconfig)" 143 + } 125 144 } 126 145 } 127 146