xp-command 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Quick cockpit commands for X-Plane 12** - set your radios, altimeter, autopilot, and more from the terminal while flying.
4
4
 
5
- | ![Screenshot 1](https://media.invisioncic.com/c334187/monthly_2025_11/ScreenRecording2025-11-02at15_01_22.gif.5f0f7b7ee4b4d19ad2717381c4bb7ca3.gif) | ![Screenshot 2](https://media.invisioncic.com/c334187/monthly_2025_11/ScreenRecording2025-11-02at14_53_18.gif.272f0344c1c36e2868f7c9bca7a8f422.gif) |
5
+ | ![screenshot1](https://github.com/user-attachments/assets/b07bda9e-6d45-430b-bbdb-26dad4c81c59) | ![screenshot2](https://github.com/user-attachments/assets/78d828c2-d838-4fcd-998d-1ac19ec2d5c8) |
6
6
  | ----------------- | ---------------- |
7
7
 
8
8
 
@@ -89,23 +89,30 @@ All pre-configured commands work well with most aircraft I currently fly, but yo
89
89
 
90
90
  ### Barometric pressure
91
91
 
92
- | Command | Action | Example |
93
- |---------|-----------------------------------------|--------------|
94
- | `q` | Get QNH in hPa/mb (copied to clipboard) | `q` → `1013` |
95
- | `l` | Get QNH in inHg (copied to clipboard) | `l` → `2992` |
96
- | `q####` | Set QNH in hPa/mb | `q1013` |
97
- | `l####` | Set QNH in inHg | `l2992` |
92
+ | Command | Action | Example |
93
+ |----------|-----------------------------------------|--------------|
94
+ | `q` | Get QNH in hPa/mb (copied to clipboard) | `q` → `1013` |
95
+ | `l` | Get QNH in inHg (copied to clipboard) | `l` → `2992` |
96
+ | `q####` | Set QNH in hPa/mb | `q1013` |
97
+ | `l####` | Set QNH in inHg | `l2992` |
98
+ | `m###` | Set BARO minimum in feet | `m200` |
99
+ | `mra###` | Set RA minimum in feet | `mra1451` |
100
+
101
+ **Minimums format:** Minimums take one to four digits and can range from 0 to 5000.
98
102
 
99
103
  ### Autopilot
100
104
 
101
- | Command | Action | Example |
102
- |----------|-----------------------------|---------------------------|
103
- | `h###` | Set heading | `h090` → 090° |
104
- | `a###` | Set altitude (flight level) | `a250` → FL250 (25000 ft) |
105
- | `a#####` | Set altitude (exact feet) | `a03500` → 3500 ft |
106
- | `s###` | Set speed in KIAS | `s180` → 180 knots |
107
- | `s##` | Set speed in Mach | `s78` → Mach 0.78 |
108
- | `v####` | Set vertical speed | `v1500` → 1500 ft/min |
105
+ | Command | Action | Example |
106
+ |----------|-----------------------------------------|---------------------------|
107
+ | `h###` | Set heading | `h090` → 090° |
108
+ | `a###` | Set altitude (flight level) | `a250` → FL250 (25000 ft) |
109
+ | `a#####` | Set altitude (exact feet) | `a03500` → 3500 ft |
110
+ | `s###` | Set speed in KIAS | `s180` → 180 knots |
111
+ | `s##` | Set speed in Mach | `s78` → Mach 0.78 |
112
+ | `v####` | Set vertical speed | `v1500` → 1500 ft/min |
113
+ | `fms` | Copy current FMS CDU1 text to clipboard | |
114
+
115
+ **The `fms` command:** This command can be very helpful, if you want to quickly paste the FMS screen content into a prompt. Note that only the first line will be shortly displayed in xp-command cli while the full text will be copied to clipboard.
109
116
 
110
117
  ### Radios
111
118
 
@@ -155,7 +162,7 @@ You can edit these YAML files to add aircraft-specific commands or modify existi
155
162
 
156
163
  **Key components:**
157
164
  - `pattern`: Regular expression matching your command (`hdg18`)
158
- - `type`: Either `get` (read value) or `set` (write value)
165
+ - `type`: Either `get` (read value and copy to clipboard) or `set` (write value)
159
166
  - `dataref`: X-Plane dataref path (find these in X-Plane's DataRef Editor)
160
167
  - `transform`: Optional value conversions (multiply, divide, round, etc.)
161
168
 
@@ -172,6 +179,19 @@ Many X-Plane datarefs are arrays (e.g., for multiple engines, generators, radios
172
179
  dataref: sim/cockpit/electrical/generator_on[1]
173
180
  ```
174
181
 
182
+ Here is an example of a custom set command which sets multiple datarefs at once (all datarefs receive the same value):
183
+
184
+ ```yaml
185
+ # toggle door and chocks
186
+ - pattern: "^d(0|1)$"
187
+ type: set
188
+ dataref:
189
+ - sim/cockpit2/switches/door_open[0]
190
+ - sim/flightmodel2/gear/is_chocked[0]
191
+ - sim/flightmodel2/gear/is_chocked[1]
192
+ - sim/flightmodel2/gear/is_chocked[2]
193
+ ```
194
+
175
195
  ## 🔄 Resetting Aircraft Profiles
176
196
 
177
197
  If you've edited an aircraft configuration and xp-command crashes or stops working, you can reset to default settings by deleting the config files.
package/bin/index.js CHANGED
@@ -12,7 +12,7 @@ import chalk from "chalk";
12
12
  import { program } from "commander";
13
13
  import ora from "ora";
14
14
 
15
- import { getDatarefValue, initAPI, setDatarefValue } from "../src/api.js";
15
+ import { getDatarefValues, initAPI, setDatarefValues } from "../src/api.js";
16
16
  import { copyToClipboard } from "../src/clipboard.js";
17
17
  import { getConfig } from "../src/config.js";
18
18
  import { clearLine, hideCursor, showCursor } from "../src/console.js";
@@ -81,12 +81,15 @@ const processCommand = async (command) => {
81
81
  return [
82
82
  new RegExp(c.pattern),
83
83
  async () => {
84
- let value = await getDatarefValue(c.dataref);
84
+ let value = await getDatarefValues(c.dataref);
85
85
  c.transform?.forEach((t) => {
86
86
  value = getTransformedValue(value, t);
87
87
  });
88
- await copyToClipboard(JSON.stringify(value));
89
- spinner.succeed(chalk.green(`${PREFIX} ${value}`));
88
+ const asString = String(value)
89
+ await copyToClipboard(asString);
90
+ const lines = asString.split('\n')
91
+ const firstLine = lines[0]
92
+ spinner.succeed(chalk.green(`${PREFIX} ${lines.length > 1 ? firstLine + '...' : firstLine}`));
90
93
  hideCursor();
91
94
  await sleep(1500);
92
95
  clearLine();
@@ -100,12 +103,12 @@ const processCommand = async (command) => {
100
103
 
101
104
  if (isNaN(Number(value))) {
102
105
  const base64 = Buffer.from(value, 'utf-8').toString('base64');
103
- await setDatarefValue(c.dataref, base64);
106
+ await setDatarefValues(c.dataref, base64);
104
107
  } else {
105
108
  c.transform?.forEach((t) => {
106
109
  value = String(getTransformedValue(value, t));
107
110
  });
108
- await setDatarefValue(c.dataref, Number(value));
111
+ await setDatarefValues(c.dataref, Number(value));
109
112
  }
110
113
  spinner.succeed(chalk.green(`${PREFIX} ${command}`));
111
114
  hideCursor();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xp-command",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Quick cockpit commands for X-Plane 12 - set your radios, altimeter, autopilot, and more from the terminal while flying.",
5
5
  "keywords": [
6
6
  "xplane",
package/src/api.js CHANGED
@@ -67,7 +67,7 @@ export const initAPI = (options) => {
67
67
 
68
68
  /**
69
69
  * @param {string} datarefNameWithOptionalIndex
70
- * @return {Promise<number|Array<number>|string>}
70
+ * @return {Promise<number|string>}
71
71
  */
72
72
  export const getDatarefValue = async (datarefNameWithOptionalIndex) => {
73
73
  const [datarefName, index] = parseDataref(datarefNameWithOptionalIndex);
@@ -106,6 +106,20 @@ export const getDatarefValue = async (datarefNameWithOptionalIndex) => {
106
106
  return JSON.stringify(json.data);
107
107
  };
108
108
 
109
+ /**
110
+ * @param {string|Array<string>} datarefNamesWithOptionalIndex
111
+ * @return {Promise<number|string>}
112
+ */
113
+ export const getDatarefValues = async (datarefNamesWithOptionalIndex) => {
114
+ if (Array.isArray(datarefNamesWithOptionalIndex)) {
115
+ return Promise.all(datarefNamesWithOptionalIndex.map(dataref => getDatarefValue(dataref))).then(results => {
116
+ return results.map(v => String(v)).join('\n').trim()
117
+ })
118
+ }
119
+
120
+ return getDatarefValue(datarefNamesWithOptionalIndex)
121
+ }
122
+
109
123
  /**
110
124
  * @param {string} datarefNameWithOptionalIndex
111
125
  * @param {number|string} value
@@ -136,3 +150,18 @@ export const setDatarefValue = async (datarefNameWithOptionalIndex, value) => {
136
150
 
137
151
  return json;
138
152
  };
153
+
154
+ /**
155
+ * @param {string|Array<string>} datarefNamesWithOptionalIndex
156
+ * @param {number|string} value
157
+ * @return {Promise<number|string>}
158
+ */
159
+ export const setDatarefValues = async (datarefNamesWithOptionalIndex, value) => {
160
+ if (Array.isArray(datarefNamesWithOptionalIndex)) {
161
+ return Promise.all(datarefNamesWithOptionalIndex.map(dataref => setDatarefValue(dataref, value))).then(results => {
162
+ return results[0]
163
+ })
164
+ }
165
+
166
+ return setDatarefValue(datarefNamesWithOptionalIndex, value)
167
+ }
package/src/config.js CHANGED
@@ -20,7 +20,7 @@ const __dirname = dirname(__filename);
20
20
  * @typedef {Object} Command
21
21
  * @property {RegExp} pattern - Regular expression pattern to match commands
22
22
  * @property {'get' | 'set'} type - Operation type
23
- * @property {string} dataref - X-Plane dataref path
23
+ * @property {string|Array<string>} dataref - X-Plane dataref path(s)
24
24
  * @property {Transform[]} transform - Array of transformation operations to apply
25
25
  */
26
26
 
package/src/config.yml CHANGED
@@ -72,7 +72,7 @@ commands:
72
72
  - mult100
73
73
  - round
74
74
 
75
- # set com1 frequency
75
+ # set COM1 frequency
76
76
  - pattern: "^c1(\\d{6})$"
77
77
  type: set
78
78
  dataref: sim/cockpit2/radios/actuators/com1_frequency_hz_833
@@ -83,7 +83,7 @@ commands:
83
83
  - mult10
84
84
  - round
85
85
 
86
- # set com1 standby frequency
86
+ # set COM1 standby frequency
87
87
  - pattern: "^cs1(\\d{6})$"
88
88
  type: set
89
89
  dataref: sim/cockpit2/radios/actuators/com1_standby_frequency_hz_833
@@ -94,7 +94,7 @@ commands:
94
94
  - mult10
95
95
  - round
96
96
 
97
- # set com2 frequency
97
+ # set COM2 frequency
98
98
  - pattern: "^c2(\\d{6})$"
99
99
  type: set
100
100
  dataref: sim/cockpit2/radios/actuators/com2_frequency_hz_833
@@ -105,7 +105,7 @@ commands:
105
105
  - mult10
106
106
  - round
107
107
 
108
- # set com2 standby frequency
108
+ # set COM2 standby frequency
109
109
  - pattern: "^cs2(\\d{6})$"
110
110
  type: set
111
111
  dataref: sim/cockpit2/radios/actuators/com2_standby_frequency_hz_833
@@ -116,32 +116,63 @@ commands:
116
116
  - mult10
117
117
  - round
118
118
 
119
- # set nav1 frequency
119
+ # set NAV1 frequency
120
120
  - pattern: "^n1(\\d{5})$"
121
121
  type: set
122
122
  dataref: sim/cockpit/radios/nav1_freq_hz
123
123
 
124
- # set nav1 standby frequency
124
+ # set NAV1 standby frequency
125
125
  - pattern: "^ns1(\\d{5})$"
126
126
  type: set
127
127
  dataref: sim/cockpit/radios/nav1_stdby_freq_hz
128
128
 
129
- # set nav2 frequency
129
+ # set NAV2 frequency
130
130
  - pattern: "^n2(\\d{5})$"
131
131
  type: set
132
132
  dataref: sim/cockpit/radios/nav2_freq_hz
133
133
 
134
- # set nav2 standby frequency
134
+ # set NAV2 standby frequency
135
135
  - pattern: "^ns2(\\d{5})$"
136
136
  type: set
137
137
  dataref: sim/cockpit/radios/nav2_stdby_freq_hz
138
-
139
- # set adf1
140
- - pattern: "^adf1((\\d{3}))$"
138
+
139
+ # set ADF1
140
+ - pattern: "^adf1(\\d{3})$"
141
141
  type: set
142
142
  dataref: sim/cockpit/radios/adf1_freq_hz
143
-
144
- # set adf2
145
- - pattern: "^adf2((\\d{3}))$"
143
+
144
+ # set ADF2
145
+ - pattern: "^adf2(\\d{3})$"
146
146
  type: set
147
147
  dataref: sim/cockpit/radios/adf2_freq_hz
148
+
149
+ # set BARO minimum
150
+ - pattern: "^m(\\d\\d?\\d?|[0-4]\\d\\d\\d|5000)$"
151
+ type: set
152
+ dataref: sim/cockpit2/gauges/actuators/baro_altimeter_bug_ft_pilot
153
+
154
+ # set RA minimum
155
+ - pattern: "^mra(\\d\\d?\\d?|[0-4]\\d\\d\\d|5000)$"
156
+ type: set
157
+ dataref: sim/cockpit/misc/radio_altimeter_minimum
158
+
159
+ # copy FMS to clipboard
160
+ - pattern: "^fm(s|c)$"
161
+ type: get
162
+ dataref:
163
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line0
164
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line1
165
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line2
166
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line3
167
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line4
168
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line5
169
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line6
170
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line7
171
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line8
172
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line9
173
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line10
174
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line11
175
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line12
176
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line13
177
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line14
178
+ - sim/cockpit2/radios/indicators/fms_cdu1_text_line15