File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
src/fprime_gds/flask/static/addons/commanding Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,27 @@ Vue.component("command-history", {
103
103
// Can only set command if it is a child of a command input
104
104
if ( this . $parent . selectCmd ) {
105
105
// command-input expects an array of strings as arguments
106
- this . $parent . selectCmd ( cmd . full_name , cmd . args . map ( el => el . toString ? el . toString ( ) : el ) ) ;
106
+ this . $parent . selectCmd ( cmd . full_name , this . preprocess_args ( cmd . args ) ) ;
107
+ }
108
+ } ,
109
+ /**
110
+ * Process the arguments for a command. If the argument is (or contains) a number, it
111
+ * is converted to a string. Other types that should be pre-processed can be added here.
112
+ *
113
+ * @param {* } args
114
+ * @returns args processed for command input (numbers converted to strings)
115
+ */
116
+ preprocess_args ( args ) {
117
+ if ( Array . isArray ( args ) ) {
118
+ return args . map ( el => this . preprocess_args ( el ) ) ;
119
+ } else if ( typeof args === 'object' && args !== null ) {
120
+ return Object . fromEntries (
121
+ Object . entries ( args ) . map ( ( [ key , value ] ) => [ key , this . preprocess_args ( value ) ] )
122
+ ) ;
123
+ } else if ( typeof args === 'number' ) {
124
+ return args . toString ( ) ;
125
+ } else {
126
+ return args ;
107
127
}
108
128
}
109
129
}
You can’t perform that action at this time.
0 commit comments