tmux_interface 0.4.0

Rust language library for communication with TMUX via CLI
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
use crate::{
    Error, GetServerOptionTr, GetServerOptionValue, GetUserOption, ServerOptions, SetClipboard,
    SetServerOption, SetServerOptionTr, SetServerOptions, SetServerOptionsTr, SetUserOption,
    ShowOptions, Switch, Tmux, TmuxCommand, TmuxOutput,
};
use std::borrow::Cow;
use std::str::FromStr;
//oneline
//multiline

// Output:
// * random (got buffer, need recognize fields)
//      * Form
//          * long (`option_name value`)
//          * short (`value`), single option get/parse (otherwise there is no chance to assign)
//
// * expected (got buffer, need to extract some fields)
//      * Form
//          * long (`option_name value`)
//          * short (`value`), single option get/parse (otherwise there is no chance to assign)
//

// get
// * get single one
// * get all for object
//
// set
// * set single one
//      * set value
//      * toggle (on/off {default}/off) if no value specified

// FIXME: proper Error in return
//
//
// ServerOption::backspace<S: Into<Cow<'a, str>>>(: Option<S>) -> Result<Self::Backspace(String), Error>
//  GetServerOption::backspace()
//  ParseServerOption::from_str()
//
// ServerOption::set().backspace<S: Into<Cow<'a, str>>>(: Option<S>) -> Result<(), Error> {
//  SetServerOption::backspace()
//  Output
// }

// XXX: rename ServerOptionCtl?
// trait top level options, then server session window pane
pub struct ServerOptionsCtl<'a> {
    // TODO: comment/doc
    //
    // function used for executing the given option get/set command
    //
    // ```
    // let tmux = Tmux::new();
    // ```
    pub invoker: &'a dyn Fn(TmuxCommand<'a>) -> Result<TmuxOutput, Error>,
}

impl<'a> Default for ServerOptionsCtl<'a> {
    fn default() -> Self {
        Self {
            invoker: &|cmd| Tmux::with_command(cmd).output(),
        }
    }
}

impl<'a> ServerOptionsCtl<'a> {
    pub fn new(invoker: &'a dyn Fn(TmuxCommand<'a>) -> Result<TmuxOutput, Error>) -> Self {
        Self { invoker }
    }

    pub fn with_invoker(invoker: &'a dyn Fn(TmuxCommand<'a>) -> Result<TmuxOutput, Error>) -> Self {
        Self { invoker }
    }

    pub fn invoker(&self) -> &'a dyn Fn(TmuxCommand<'a>) -> Result<TmuxOutput, Error> {
        self.invoker
    }

    pub fn get_all(&self) -> Result<ServerOptions<'a>, Error> {
        Self::get_all_ext(self.invoker)
    }

    pub fn get_all_ext(
        invoker: impl FnOnce(TmuxCommand<'a>) -> Result<TmuxOutput, Error>,
    ) -> Result<ServerOptions<'a>, Error> {
        let cmd = ShowOptions::new().server().build();
        let output = invoker(cmd)?.to_string();
        ServerOptions::from_str(&output)
    }

    pub fn set_all(&self, server_options: ServerOptions<'a>) -> Result<TmuxOutput, Error> {
        Self::set_all_ext(self.invoker(), server_options)
    }

    pub fn set_all_ext(
        invoker: impl FnOnce(TmuxCommand<'a>) -> Result<TmuxOutput, Error>,
        server_options: ServerOptions<'a>,
    ) -> Result<TmuxOutput, Error> {
        let cmds = SetServerOptions::new();

        #[cfg(feature = "tmux_3_1")]
        let cmds = cmds.backspace(server_options.backspace);

        #[cfg(feature = "tmux_1_5")]
        let cmds = cmds.buffer_limit(server_options.buffer_limit);

        #[cfg(feature = "tmux_2_4")]
        let cmds = cmds.command_alias(server_options.command_alias);

        #[cfg(feature = "tmux_3_2")]
        let cmds = cmds.copy_command(server_options.copy_command);

        #[cfg(feature = "tmux_2_1")]
        let cmds = cmds.default_terminal(server_options.default_terminal);

        #[cfg(feature = "tmux_1_2")]
        let cmds = cmds.escape_time(server_options.escape_time);

        #[cfg(feature = "tmux_3_2")]
        let cmds = cmds.editor(server_options.editor);

        #[cfg(feature = "tmux_2_7")]
        let cmds = cmds.exit_empty(server_options.exit_empty);

        #[cfg(feature = "tmux_1_4")]
        let cmds = cmds.exit_unattached(server_options.exit_unattached);

        #[cfg(feature = "tmux_3_2")]
        let cmds = cmds.extended_keys(server_options.extended_keys);

        #[cfg(feature = "tmux_1_9")]
        let cmds = cmds.focus_events(server_options.focus_events);

        #[cfg(feature = "tmux_2_1")]
        let cmds = cmds.history_file(server_options.history_file);

        #[cfg(feature = "tmux_2_0")]
        let cmds = cmds.message_limit(server_options.message_limit);

        #[cfg(feature = "tmux_3_3")]
        let cmds = cmds.prompt_history_limit(server_options.prompt_history_limit);

        #[cfg(feature = "tmux_1_5")]
        let cmds = cmds.set_clipboard(server_options.set_clipboard);

        #[cfg(feature = "tmux_3_2")]
        let cmds = cmds.terminal_features(server_options.terminal_features);

        #[cfg(feature = "tmux_2_0")]
        let cmds = cmds.terminal_overrides(server_options.terminal_overrides);

        #[cfg(feature = "tmux_3_0")]
        let cmds = cmds.user_keys(server_options.user_keys);

        #[cfg(all(feature = "tmux_1_2", not(feature = "tmux_2_0")))]
        let cmds = cmds.quiet(server_options.quiet);

        #[cfg(all(feature = "tmux_1_3", not(feature = "tmux_1_4")))]
        let cmds = cmds.detach_on_destroy(server_options.detach_on_destroy);

        // `@USER_OPTION`

        let cmd = TmuxCommand::with_cmds(cmds.build());

        invoker(cmd)
    }

    // get and parse single line option
    pub fn get<T: std::str::FromStr>(&self, cmd: TmuxCommand<'a>) -> Result<Option<T>, Error> {
        Ok((self.invoker)(cmd)?.to_string().trim().parse::<T>().ok())
    }

    pub fn set(&self, cmd: TmuxCommand<'a>) -> Result<TmuxOutput, Error> {
        (self.invoker)(cmd)
    }

    // FIXME: full array support
    // Tmux binary
    //
    // 1. multiple binary call
    // tmux set -s command-alias[0] value0
    // tmux set -s command-alias[1] value1
    // tmux set -s command-alias[2] value2
    //
    // 2. single binary call
    // tmux set -s command-alias[0] value0 ; set -s command-alias[1] ; set -s command-alias[2]
    //
    // Control Mode
    //
    // 1. multiple control mode commands
    // set -s command-alias[0] value0
    // set -s command-alias[1] value1
    // set -s command-alias[2] value2
    //
    // 2. single control mode command
    // set -s command-alias[0] value0 ; set -s command-alias[1] ; set -s command-alias[2]
    //
    pub fn get_array(&self, get_option_cmd: TmuxCommand<'a>) -> Result<Option<Vec<String>>, Error> {
        let output = (self.invoker)(get_option_cmd)?;
        let v: Vec<String> = output
            .to_string()
            .lines()
            .map(|s| s.trim().into())
            .collect();
        let result = match v.is_empty() {
            true => None,
            false => Some(v),
        };
        Ok(result)
    }

    // pub fn set_array(&self, values: Vec<String>) -> Result<TmuxOutput, Error> {
    // let cmd = TmuxCommand::new();
    // let output = (self.invoker)(cmd);
    //
    // for (i, value) in values.iter().enumerate() {}
    //
    // output
    // }
}

impl<'a> ServerOptionsCtl<'a> {
    /// ### Manual
    ///
    /// tmux ^3.1:
    /// ```text
    /// backspace key
    /// ```
    #[cfg(feature = "tmux_3_1")]
    pub fn get_backspace(&self) -> Result<Option<String>, Error> {
        self.get(GetServerOptionValue::backspace())
    }

    /// ### Manual
    ///
    /// tmux ^3.1:
    /// ```text
    /// backspace key
    /// ```
    #[cfg(feature = "tmux_3_1")]
    pub fn set_backspace(&self, key: Option<String>) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::backspace(key))
    }

    /// ### Manual
    ///
    /// tmux ^1.5:
    /// ```text
    /// buffer-limit number
    /// ```
    #[cfg(feature = "tmux_1_5")]
    pub fn get_buffer_limit(&self) -> Result<Option<usize>, Error> {
        self.get(GetServerOptionValue::buffer_limit())
    }

    /// ### Manual
    ///
    /// tmux ^1.5:
    /// ```text
    /// buffer-limit number
    /// ```
    #[cfg(feature = "tmux_1_5")]
    pub fn set_buffer_limit(&self, buffer_limit: Option<usize>) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::buffer_limit(buffer_limit))
    }

    /// ### Manual
    ///
    /// tmux ^2.4:
    /// ```text
    /// command-alias[] name=value
    /// ```
    #[cfg(feature = "tmux_2_4")]
    pub fn get_command_alias(&self) -> Result<Option<Vec<String>>, Error> {
        self.get_array(GetServerOptionValue::command_alias())
    }

    /// ### Manual
    ///
    /// tmux ^2.4:
    /// ```text
    /// command-alias[] name=value
    /// ```
    #[cfg(feature = "tmux_2_4")]
    pub fn set_command_alias<I, S>(&self, command_alias: Option<I>) -> Result<TmuxOutput, Error>
    where
        I: IntoIterator<Item = S>,
        S: Into<Cow<'a, str>>,
    {
        self.set(TmuxCommand::with_cmds(SetServerOption::command_alias(
            command_alias,
        )))
    }

    /// ### Manual
    ///
    /// tmux ^3.2:
    /// ```text
    /// copy-command shell-command
    /// ```
    #[cfg(feature = "tmux_3_2")]
    pub fn get_copy_command(&self) -> Result<Option<String>, Error> {
        self.get(GetServerOptionValue::copy_command())
    }

    /// ### Manual
    ///
    /// tmux ^3.2:
    /// ```text
    /// copy-command shell-command
    /// ```
    #[cfg(feature = "tmux_3_2")]
    pub fn set_copy_command(&self, copy_command: Option<String>) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::copy_command(copy_command))
    }

    /// ### Manual
    ///
    /// tmux ^2.1:
    /// ```text
    /// default-terminal terminal
    /// ```
    #[cfg(feature = "tmux_2_1")]
    pub fn get_default_terminal(&self) -> Result<Option<String>, Error> {
        self.get(GetServerOptionValue::default_terminal())
    }

    /// ### Manual
    ///
    /// tmux ^2.1:
    /// ```text
    /// default-terminal terminal
    /// ```
    #[cfg(feature = "tmux_2_1")]
    pub fn set_default_terminal(
        &self,
        default_terminal: Option<String>,
    ) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::default_terminal(default_terminal))
    }

    /// ### Manual
    ///
    /// tmux ^1.2:
    /// ```text
    /// escape-time time
    /// ```
    #[cfg(feature = "tmux_1_2")]
    pub fn get_escape_time(&self) -> Result<Option<usize>, Error> {
        self.get(GetServerOptionValue::escape_time())
    }

    /// ### Manual
    ///
    /// tmux ^1.2:
    /// ```text
    /// escape-time time
    /// ```
    #[cfg(feature = "tmux_1_2")]
    pub fn set_escape_time(&self, escape_time: Option<usize>) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::escape_time(escape_time))
    }

    /// ### Manual
    ///
    /// tmux ^3.2:
    /// ```text
    /// editor shell-command
    /// ```
    #[cfg(feature = "tmux_3_2")]
    pub fn get_editor(&self) -> Result<Option<String>, Error> {
        self.get(GetServerOptionValue::editor())
    }

    /// ### Manual
    ///
    /// tmux ^3.2:
    /// ```text
    /// editor shell-command
    /// ```
    #[cfg(feature = "tmux_3_2")]
    pub fn set_editor<S>(&self, editor: Option<S>) -> Result<TmuxOutput, Error>
    where
        S: Into<Cow<'a, str>>,
    {
        self.set(SetServerOption::editor(editor))
    }

    /// ### Manual
    ///
    /// tmux ^2.7:
    /// ```text
    /// exit-empty [on | off]
    /// ```
    #[cfg(feature = "tmux_2_7")]
    pub fn get_exit_empty(&self) -> Result<Option<Switch>, Error> {
        self.get(GetServerOptionValue::exit_empty())
    }

    /// ### Manual
    ///
    /// tmux ^2.7:
    /// ```text
    /// exit-empty [on | off]
    /// ```
    #[cfg(feature = "tmux_2_7")]
    pub fn set_exit_empty(&self, exit_empty: Option<Switch>) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::exit_empty(exit_empty))
    }

    /// ### Manual
    ///
    /// tmux ^1.4:
    /// ```text
    /// exit-unattached [on | off]
    /// ```
    #[cfg(feature = "tmux_1_4")]
    pub fn get_exit_unattached(&self) -> Result<Option<Switch>, Error> {
        self.get(GetServerOptionValue::exit_unattached())
    }

    /// ### Manual
    ///
    /// tmux ^1.4:
    /// ```text
    /// exit-unattached [on | off]
    /// ```
    #[cfg(feature = "tmux_1_4")]
    pub fn set_exit_unattached(
        &self,
        exit_unattached: Option<Switch>,
    ) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::exit_unattached(exit_unattached))
    }

    /// ### Manual
    ///
    /// tmux ^3.2:
    /// ```text
    /// extended-keys [on | off]
    /// ```
    #[cfg(feature = "tmux_3_2")]
    pub fn get_extended_keys(&self) -> Result<Option<Switch>, Error> {
        self.get(GetServerOptionValue::extended_keys())
    }

    /// ### Manual
    ///
    /// tmux ^3.2:
    /// ```text
    /// extended-keys [on | off]
    /// ```
    #[cfg(feature = "tmux_3_2")]
    pub fn set_extended_keys(&self, extended_keys: Option<Switch>) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::extended_keys(extended_keys))
    }

    /// ### Manual
    ///
    /// tmux ^1.9:
    /// ```text
    /// focus-events [on | off]
    /// ```
    #[cfg(feature = "tmux_1_9")]
    pub fn get_focus_events(&self) -> Result<Option<Switch>, Error> {
        self.get(GetServerOptionValue::focus_events())
    }

    /// ### Manual
    ///
    /// tmux ^1.9:
    /// ```text
    /// focus-events [on | off]
    /// ```
    #[cfg(feature = "tmux_1_9")]
    pub fn set_focus_events(&self, focus_events: Option<Switch>) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::focus_events(focus_events))
    }

    /// ### Manual
    ///
    /// tmux ^2.1:
    /// ```text
    /// history-file path
    /// ```
    #[cfg(feature = "tmux_2_1")]
    pub fn get_history_file(&self) -> Result<Option<String>, Error> {
        self.get(GetServerOptionValue::history_file())
    }

    /// ### Manual
    ///
    /// tmux ^2.1:
    /// ```text
    /// history-file path
    /// ```
    #[cfg(feature = "tmux_2_1")]
    pub fn set_history_file(&self, history_file: Option<String>) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::history_file(history_file))
    }

    /// ### Manual
    ///
    /// tmux ^2.0:
    /// ```text
    /// message-limit number
    /// ```
    #[cfg(feature = "tmux_2_0")]
    pub fn get_message_limit(&self) -> Result<Option<usize>, Error> {
        self.get(GetServerOptionValue::message_limit())
    }

    /// ### Manual
    ///
    /// tmux ^2.0:
    /// ```text
    /// message-limit number
    /// ```
    #[cfg(feature = "tmux_2_0")]
    pub fn set_message_limit(&self, message_limit: Option<usize>) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::message_limit(message_limit))
    }

    /// ### Manual
    ///
    /// tmux ^3.3:
    /// ```text
    /// prompt-history-limit number
    /// ```
    #[cfg(feature = "tmux_3_3")]
    pub fn get_prompt_history_limit(&self) -> Result<Option<usize>, Error> {
        self.get(GetServerOptionValue::prompt_history_limit())
    }

    /// ### Manual
    ///
    /// tmux ^3.3:
    /// ```text
    /// prompt-history-limit number
    /// ```
    #[cfg(feature = "tmux_3_3")]
    pub fn set_prompt_history_limit(
        &self,
        prompt_history_limit: Option<usize>,
    ) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::prompt_history_limit(prompt_history_limit))
    }

    /// ### Manual
    ///
    /// tmux ^1.5:
    /// ```text
    /// set-clipboard [on | external | off]
    /// ```
    #[cfg(feature = "tmux_1_5")]
    pub fn get_set_clipboard(&self) -> Result<Option<SetClipboard>, Error> {
        self.get(GetServerOptionValue::set_clipboard())
    }

    /// ### Manual
    ///
    /// tmux ^1.5:
    /// ```text
    /// set-clipboard [on | external | off]
    /// ```
    #[cfg(feature = "tmux_1_5")]
    pub fn set_set_clipboard(
        &self,
        set_clipboard: Option<SetClipboard>,
    ) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::set_clipboard(set_clipboard))
    }

    /// ### Manual
    ///
    /// tmux ^3.2:
    /// ```text
    /// terminal-features[] string
    /// ```
    #[cfg(feature = "tmux_3_2")]
    pub fn get_terminal_features(&self) -> Result<Option<Vec<String>>, Error> {
        self.get_array(GetServerOptionValue::terminal_features())
    }

    /// ### Manual
    ///
    /// tmux ^3.2:
    /// ```text
    /// terminal-features[] string
    /// ```
    #[cfg(feature = "tmux_3_2")]
    pub fn set_terminal_features<I, S>(
        &self,
        terminal_features: Option<I>,
    ) -> Result<TmuxOutput, Error>
    where
        I: IntoIterator<Item = S>,
        S: Into<Cow<'a, str>>,
    {
        self.set(TmuxCommand::with_cmds(SetServerOption::terminal_features(
            terminal_features,
        )))
    }

    /// ### Manual
    ///
    /// tmux ^2.0:
    /// ```text
    /// terminal-overrides[] string
    /// ```
    #[cfg(feature = "tmux_2_0")]
    pub fn get_terminal_overrides(&self) -> Result<Option<Vec<String>>, Error> {
        self.get_array(GetServerOptionValue::terminal_overrides())
    }

    /// ### Manual
    ///
    /// tmux ^2.0:
    /// ```text
    /// terminal-overrides[] string
    /// ```
    #[cfg(feature = "tmux_2_0")]
    pub fn set_terminal_overrides<I, S>(
        &self,
        terminal_overrides: Option<I>,
    ) -> Result<TmuxOutput, Error>
    where
        I: IntoIterator<Item = S>,
        S: Into<Cow<'a, str>>,
    {
        self.set(TmuxCommand::with_cmds(SetServerOption::terminal_overrides(
            terminal_overrides,
        )))
    }

    /// ### Manual
    ///
    /// tmux ^3.0:
    /// ```text
    /// user-keys[] key
    /// ```
    #[cfg(feature = "tmux_3_0")]
    pub fn get_user_keys(&self) -> Result<Option<Vec<String>>, Error> {
        self.get_array(GetServerOptionValue::user_keys())
    }

    /// ### Manual
    ///
    /// tmux ^3.0:
    /// ```text
    /// user-keys[] key
    /// ```
    #[cfg(feature = "tmux_3_0")]
    pub fn set_user_keys<I, S>(&self, user_keys: Option<I>) -> Result<TmuxOutput, Error>
    where
        I: IntoIterator<Item = S>,
        S: Into<Cow<'a, str>>,
    {
        self.set(TmuxCommand::with_cmds(SetServerOption::user_keys(
            user_keys,
        )))
    }

    /// ### Manual
    ///
    /// tmux ^1.2 v2.0:
    /// ```text
    /// quiet [on | off]
    /// ```
    #[cfg(all(feature = "tmux_1_2", not(feature = "tmux_2_0")))]
    pub fn get_quiet(&self) -> Result<Option<Switch>, Error> {
        self.get(GetServerOptionValue::quiet())
    }

    /// ### Manual
    ///
    /// tmux ^1.2 v2.0:
    /// ```text
    /// quiet [on | off]
    /// ```
    #[cfg(all(feature = "tmux_1_2", not(feature = "tmux_2_0")))]
    pub fn set_quiet(&self, quiet: Option<Switch>) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::quiet(quiet))
    }

    /// ### Manual
    ///
    /// tmux ^1.3 v1.4:
    /// ```text
    /// detach-on-destroy [on | off]
    /// ```
    #[cfg(all(feature = "tmux_1_3", not(feature = "tmux_1_4")))]
    pub fn get_detach_on_destroy(&self) -> Result<Option<Switch>, Error> {
        self.get(GetServerOptionValue::detach_on_destroy())
    }

    /// ### Manual
    ///
    /// tmux ^1.3 v1.4:
    /// ```text
    /// detach-on-destroy [on | off]
    /// ```
    #[cfg(all(feature = "tmux_1_3", not(feature = "tmux_1_4")))]
    pub fn set_detach_on_destroy(
        &self,
        detach_on_destroy: Option<Switch>,
    ) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::detach_on_destroy(detach_on_destroy))
    }

    // XXX: get/set multiple user options

    /// # Manual
    ///
    /// tmux:
    /// ```text
    /// @user-option-name value
    /// ```
    pub fn get_user_option<S: Into<Cow<'a, str>>>(&self, name: S) -> Result<Option<String>, Error> {
        self.get(GetServerOptionValue::user_option(name))
    }

    /// # Manual
    ///
    /// tmux:
    /// ```text
    /// @user-option-name value
    /// ```
    pub fn set_user_option<S: Into<Cow<'a, str>>, T: Into<Cow<'a, str>>>(
        &self,
        name: S,
        value: Option<T>,
    ) -> Result<TmuxOutput, Error> {
        self.set(SetServerOption::user_option(name, value))
    }
}