File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -11,5 +11,5 @@ rustflags = [
11
11
]
12
12
13
13
[alias]
14
- files = "run --bin swift-files --no-default-features --features env_logger,indicatif --"
15
- settings = "run --bin swift-settings --no-default-features --features env_logger --"
14
+ swift- files = "run --bin swift-files --no-default-features --features env_logger,indicatif --"
15
+ swift- settings = "run --bin swift-settings --no-default-features --features env_logger --"
Original file line number Diff line number Diff line change @@ -171,7 +171,14 @@ impl SettingsTab {
171
171
}
172
172
173
173
pub fn export ( & self , path : & Path ) -> Result < ( ) > {
174
- let mut f = fs:: File :: create ( path) ?;
174
+ if path. to_string_lossy ( ) == "-" {
175
+ self . export_impl ( std:: io:: stdout ( ) )
176
+ } else {
177
+ self . export_impl ( fs:: File :: create ( path) ?)
178
+ }
179
+ }
180
+
181
+ fn export_impl < T : std:: io:: Write > ( & self , mut f : T ) -> Result < ( ) > {
175
182
let settings = self . settings . lock ( ) ;
176
183
let groups = settings. groups ( ) ;
177
184
let mut conf = Ini :: new ( ) ;
@@ -187,7 +194,14 @@ impl SettingsTab {
187
194
}
188
195
189
196
pub fn import ( & self , path : & Path ) -> Result < ( ) > {
190
- let mut f = fs:: File :: open ( path) ?;
197
+ if path. to_string_lossy ( ) == "-" {
198
+ self . import_impl ( std:: io:: stdin ( ) )
199
+ } else {
200
+ self . import_impl ( fs:: File :: create ( path) ?)
201
+ }
202
+ }
203
+
204
+ pub fn import_impl < T : std:: io:: Read > ( & self , mut f : T ) -> Result < ( ) > {
191
205
let conf = Ini :: read_from ( & mut f) ?;
192
206
let old_ethernet = self . set_if_group_changes (
193
207
& conf,
You can’t perform that action at this time.
0 commit comments