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
// First variant:
// 1. build commands
// 2. push commands
//
// NOTE:
// error move occurs because value has type `TmuxCommand<'_>`, which does not implement the `Copy`
// trait
//
// fix: impl from &mut NewSession into TmuxCommand trait
//
// Second variant:
// 1. push in place created
//#[test]
//fn tmux_commands_push2() {
//use crate::commands::tmux_commands::TmuxCommands;
//use crate::{HasSession, KillSession, NewSession, TmuxCommand};
//let mut cmds = TmuxCommands::new();
//cmds.push(NewSession::new().detached().session_name("session").build());
//cmds.push(HasSession::new().target_session("session").build());
//cmds.push(KillSession::new().target_session("session").build());
//cmds.push(TmuxCommand::new());
//dbg!(cmds);
//}
// nice would be?
//#[test]
//fn tmux_commands_push2() {
//use crate::commands::tmux_commands::TmuxCommands;
//use crate::{HasSession, KillSession, NewSession, TmuxCommand};
//let mut cmds = TmuxCommands::new();
//cmds.new_session().detached().session_name("session");
//cmds.has_session().target_session("session");
//cmds.kill_session().target_session("session");
//dbg!(cmds);
//}
//
//
// NOTE: from bin
//// TODO: All in one variants demo
//
//#[test]
//fn tmux_bin_commands() {
//use crate::commands::tmux_bin_commands::TmuxBinCommands;
//use crate::{HasSession, KillSession, ListSessions, NewSession};
//let target_session = "example2";
//let target_session = String::from("example2");
//let mut cmds = TmuxBinCommands::new();
//cmds.push(NewSession::new().detached().session_name(target_session));
//cmds.push(HasSession::new().target_session(target_session));
//cmds.push(KillSession::new().target_session(target_session));
//cmds.output().unwrap();
//}
//#[test]
//fn tmux_bin_commands2() {
//use crate::commands::tmux_bin_commands::TmuxBinCommands;
//use crate::{ListCommands, ShowOptions, StartServer};
////let tmux = TmuxBin::default();
////let mut tmux = TmuxBin::new();
////tmux.bin("tmux");
////tmux.bin = Some("tmux");
////let mut cmds = TmuxBinCommands::from(tmux);
//let mut cmds = TmuxBinCommands::default();
//cmds.tmux.verbose();
//// E0716
////let list_commands = ListCommands::new().format("1");
////cmds.push(list_commands);
//// OK build(self) consuming
////let mut list_commands = ListCommands::new();
////list_commands.format("1");
////cmds.push(list_commands.build());
//// OK build(self) consuming
//let mut list_commands = ListCommands::new();
//list_commands.format("1");
//cmds.push(&list_commands);
//// E0716
////cmds.push(ListCommands::new().format("1"));
//let start_server = StartServer::new();
//cmds.push(start_server.build());
//// return type transfer Self -> &mut self -> Command
//// non consuming builders preferred
//let mut list_commands = ListCommands::new();
//list_commands.format("#{command_list_alias}");
//cmds.push(&list_commands);
//let mut show_options1 = ShowOptions::new();
//show_options1.global().option("default-shell");
//cmds.push(show_options1.build());
//// E0716
//// can be fixed using consumable builder pattern
////cmds.push(ListCommands::new().format("1").build().to_owned());
//let mut show_options2 = ShowOptions::new();
//show_options2.global().option("default-shell");
//cmds.push(show_options2.build());
//dbg!(&cmds);
//let result = cmds.output().unwrap();
//dbg!(&result);
//}
//#[test]
//fn tmux_bin_commands2() {
//let cmds = TmuxBinCommands::default();
//cmds.new_session().detached().session_name("kd").build();
//cmds.has_session().session_name("kd").build();
//cmds.kill_session()
//}