@@ -27,6 +27,69 @@ class WorkspaceBuilder:
27
27
Build tmux workspace from a configuration. Creates and names windows, sets
28
28
options, splits windows into panes.
29
29
30
+ Examples
31
+ --------
32
+
33
+ >>> import yaml
34
+
35
+ >>> session_config = yaml.load('''
36
+ ... session_name: sampleconfig
37
+ ... start_directory: '~'
38
+ ... windows:
39
+ ... - window_name: editor
40
+ ... layout: main-vertical
41
+ ... panes:
42
+ ... - shell_command:
43
+ ... - cmd: vim
44
+ ... - shell_command:
45
+ ... - cmd: echo "hey"
46
+ ...
47
+ ... - window_name: logging
48
+ ... panes:
49
+ ... - shell_command:
50
+ ... - cmd: tail | echo 'hi'
51
+ ...
52
+ ... - window_name: test
53
+ ... panes:
54
+ ... - shell_command:
55
+ ... - cmd: htop
56
+ ... ''', Loader=yaml.Loader)
57
+
58
+ >>> builder = WorkspaceBuilder(sconf=session_config, server=server)
59
+
60
+ ***New session:**
61
+
62
+ >>> builder.build()
63
+
64
+ >>> new_session = builder.session
65
+
66
+ >>> new_session.name == 'sampleconfig'
67
+ True
68
+
69
+ >>> len(new_session._windows)
70
+ 3
71
+
72
+ >>> sorted([window.name for window in new_session.windows])
73
+ ['editor', 'logging', 'test']
74
+
75
+ **Existing session**
76
+
77
+ >>> len(session._windows)
78
+ 1
79
+
80
+ >>> builder.build(session=session)
81
+
82
+ _Caveat:_ Preserves old session name:
83
+
84
+ >>> session.name == 'sampleconfig'
85
+ False
86
+
87
+ >>> len(session._windows)
88
+ 3
89
+
90
+ >>> sorted([window.name for window in session.windows])
91
+ ['editor', 'logging', 'test']
92
+
30
93
The normal phase of loading is:
31
94
32
95
1. :term:`kaptan` imports json/yaml/ini. ``.get()`` returns python
0 commit comments