github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/config/defaults/profile_any.mx (about) 1 alias help=murex-docs 2 3 autocomplete set murex-docs %[ { 4 FlagsDesc: { 5 --docs: "Returns a JSON object of every document available to read offline" 6 --summary: "Returns an abridged description of the command rather than the entire help page" 7 } 8 DynamicDesc: '{ fexec builtin murex-docs --docs }' 9 FlagValues: { 10 --summary: [{ 11 Dynamic: '{ fexec builtin murex-docs --docs }' 12 }] 13 } 14 ListView: true 15 } ] 16 17 autocomplete set help autocomplete(get murex-docs) 18 19 alias builtin=fexec builtin 20 alias command=exec 21 22 alias echo=out 23 method define echo %{ 24 Stdin: null 25 Stdout: str 26 } 27 config eval shell safe-commands { 28 -> alter --merge / %[ echo ] 29 } 30 31 private autocomplete.test.run-unit { 32 # Returns all available tests for `test run` 33 runtime: --tests -> [ unit ] -> foreach: test { 34 out: $test[function] 35 } -> cast str -> prepend * 36 } 37 38 test unit private autocomplete.test.run-unit %{ 39 StdoutRegex: '^(([-_./a-zA-Z0-9]+|\*)\n)+' 40 StdoutType: str 41 StdoutGreaterThan: 1 42 StdoutIsArray: true 43 } 44 45 autocomplete set test %[ 46 { 47 FlagsDesc: { 48 config: "Enable or disable boolean test states (more options available in `config test ...`)" 49 define: "Define an inlined test" 50 state: "Define a state report" 51 run: "Execute a code block, function or unit test with inline testing enabled" 52 unit: "Define a unit test" 53 report: "Write the test report (happens automatically by default)" 54 } 55 FlagValues: { 56 config: [{ 57 FlagsDesc: { 58 enable: "Enable inlined tests" 59 !enable: "Disable inlined tests" 60 auto-report: "Automatically output report (default)" 61 !auto-report: "Do not automatically output report" 62 verbose: "Verbose report" 63 !verbose: "Concise report (default)" 64 } 65 AllowMultiple: true 66 Optional: false 67 }] 68 run: [{ 69 Dynamic: '{ autocomplete.test.run-unit }' 70 }] 71 } 72 } 73 ] 74 75 function h { 76 # Output the murex history log in a human readable format 77 78 history \ 79 -> foreach { 80 -> set json line 81 out "$line[Index]: $line[Block]" 82 } \ 83 -> cast * 84 } 85 86 function aliases { 87 # Output the aliases in human readable format 88 89 cast str 90 runtime --aliases \ 91 -> formap k v { 92 out "$k => ${esccli @v.Alias}" 93 } \ 94 -> sort 95 } 96 97 test unit function aliases %{ 98 PreBlock: '{ 99 alias ALIAS_UNIT_TEST=example param1 param2 param3 100 }' 101 PostBlock: '{ 102 !alias ALIAS_UNIT_TEST 103 }' 104 StdoutRegex: '([- _0-9a-zA-Z]+ => .*?\n)+' 105 StdoutType: str 106 } 107 108 autocomplete set exec %[ 109 { 110 IncFiles: true 111 IncDirs: true 112 IncExePath: true 113 } 114 { 115 NestedCommand: true 116 } 117 ] 118 119 autocomplete set format %[{ 120 Dynamic: '{ runtime --marshallers }' 121 }] 122 123 private autocomplete.data-types { 124 # Returns all murex data-types compiled 125 126 cast str 127 runtime --readarray -> format str 128 runtime --readarraywithtype -> format str 129 runtime --writearray -> format str 130 runtime --readmap -> format str 131 runtime --marshallers -> format str 132 runtime --unmarshallers -> format str 133 } 134 135 test unit private autocomplete.data-types %{ 136 StdoutRegex: '^(([a-z0-9]+|\*)\n)+' 137 StdoutType: str 138 StdoutGreaterThan: 1 139 StdoutIsArray: true 140 } 141 142 autocomplete set cast %[{ 143 Dynamic: '{ autocomplete.data-types }' 144 }] 145 146 autocomplete set tout %[{ 147 Dynamic: '{ autocomplete.data-types }' 148 }] 149 150 private autocomplete.variables.locals { 151 # Returns all local variable names 152 153 cast str 154 runtime --variables -> formap k v { out $k } 155 } 156 157 private autocomplete.variables.globals { 158 # Returns all global variable names 159 160 cast str 161 runtime --globals -> formap k v { out $k } 162 } 163 164 private autocomplete.variables { 165 # Returns all global and local variable names 166 167 cast str 168 autocomplete.variables.locals 169 autocomplete.variables.globals 170 } 171 172 test unit private autocomplete.variables %{ 173 PreBlock: '{ 174 GLOBAL.MUREX_UNIT_TEST = "foobar" 175 }' 176 PostBlock: '{ 177 !global MUREX_UNIT_TEST 178 }' 179 StdoutRegex: '([_a-zA-Z0-9]+\n)+' 180 StdoutType: str 181 StdoutGreaterThan: 1 182 StdoutIsArray: true 183 } 184 185 autocomplete: set set %[{ 186 Dynamic: '{ autocomplete.variables.locals }' 187 AnyValue: true 188 }] 189 190 autocomplete: set !set %[{ 191 Dynamic: '{ autocomplete.variables.locals }' 192 }] 193 194 autocomplete set global %[{ 195 Dynamic: '{ autocomplete.variables.globals }' 196 AnyValue: true 197 }] 198 199 autocomplete set !global %[{ 200 Dynamic: '{ autocomplete.variables.globals }' 201 }] 202 203 autocomplete set export %[ 204 { 205 Dynamic: '{ autocomplete.variables }' 206 AnyValue: true 207 } 208 { 209 IncDirs: true 210 } 211 ] 212 213 autocomplete set !export %[{ 214 DynamicDesc: '{ runtime --exports }' 215 }] 216 217 autocomplete set unset %[{ 218 DynamicDesc: '{ runtime --exports }' 219 }] 220 221 private autocomplete.pipe-types { 222 # Returns CLI flags for pipe 223 224 runtime --pipes \ 225 -> !match std \ 226 -> prefix "--" 227 } 228 229 test unit private autocomplete.pipe-types %{ 230 StdoutRegex: "--file" 231 } 232 233 autocomplete set pipe %[ 234 { 235 AnyValue: true 236 } 237 { 238 Dynamic: '{ autocomplete.pipe-types }' 239 FlagValues: { 240 --file: [{ IncFiles: true }] 241 } 242 } 243 ] 244 245 private autocomplete.!pipe-list { 246 # Returns CLI flags for ` + "`!pipe`" + ` 247 runtime: --named-pipes -> ![ null ] 248 } 249 250 test unit private autocomplete.!pipe-list %{ 251 PreBlock: '{ pipe autocompleteunittest }' 252 PostBlock: '{ !pipe autocompleteunittest }' 253 StdoutRegex: "autocompleteunittest" 254 } 255 256 autocomplete set !pipe %[{ 257 DynamicDesc: '{ autocomplete.!pipe-list }' 258 AllowMultiple: true 259 }] 260 261 private autocomplete.index { 262 switch ${ get-type stdin } { 263 264 case * { 265 <stdin> \ 266 -> [ 0: ] \ 267 -> format json \ 268 -> [ 0 ] \ 269 -> append "]" 270 } 271 272 case csv { 273 <stdin> \ 274 -> [ 0: ] \ 275 -> format json \ 276 -> [ 0 ] \ 277 -> append "]" 278 } 279 280 case jsonl { 281 <stdin> \ 282 -> [ 0 ] \ 283 -> set header 284 285 $header \ 286 -> cast utf8 \ 287 -> [ 0 -1 ] \ 288 -> set jsonl_format 289 290 if { $jsonl_format == "[]" } then { 291 tout json $header \ 292 -> append "]" 293 } 294 } 295 296 catch { 297 <stdin> \ 298 -> formap k v { out $k } \ 299 -> cast str \ 300 -> append "]" \ 301 -> format json 302 } 303 } 304 } 305 306 autocomplete set "[" %[{ 307 AnyValue: true 308 AllowMultiple: true 309 ExecCmdline: true 310 Dynamic: '{ autocomplete.index }' 311 312 }] 313 314 autocomplete: set "[[" %[{ 315 AnyValue: true 316 ExecCmdline: true 317 AutoBranch: true 318 Dynamic: '{ -> struct-keys -> append "]]" }' 319 }] 320 321 private autocomplete.config.get.apps { 322 # Returns all app names for the 'app' field in `config` 323 config: -> formap k v { out $k } -> cast: str -> msort 324 } 325 326 test unit private autocomplete.config.get.apps %{ 327 StdoutRegex: "shell" 328 StdoutType: str 329 StdoutGreaterThan: 1 330 StdoutIsArray: true 331 } 332 333 private autocomplete.config.get.keys { 334 # Returns all keys for the 'app' field in `config` 335 336 config \ 337 -> [ $PARAMS[0] ] \ 338 -> formap k v { out $k } \ 339 -> cast str 340 } 341 342 test unit private autocomplete.config.get.keys %{ 343 Parameters: [ shell ] 344 StdoutRegex: prompt 345 StdoutType: str 346 StdoutGreaterThan: 1 347 StdoutIsArray: true 348 } 349 350 autocomplete: set config %[{ 351 Flags: [ get set eval define default ] 352 FlagValues: { 353 get: [ 354 { Dynamic: '{ autocomplete.config.get.apps }' } 355 { Dynamic: '{ autocomplete.config.get.keys $PARAMS[1] }' } 356 ], 357 set: [ 358 { Dynamic: '{ autocomplete.config.get.apps }' } 359 { Dynamic: '{ autocomplete.config.get.keys $PARAMS[1] }' } 360 { Dynamic: '{ 361 switch { 362 case { ${ config -> [[ /$PARAMS[1]/$PARAMS[2]/Data-Type ]] } == "bool" } { 363 %[true false] 364 } 365 366 case { config -> [ $PARAMS[1] ] -> [ $PARAMS[2] ] -> [ <!null> Options ] } { 367 config -> [[ /$PARAMS[1]/$PARAMS[2]/Options ]] 368 } 369 370 catch { 371 config -> [[ /$PARAMS[1]/$PARAMS[2]/Default ]] 372 } 373 } 374 }' } 375 ] 376 eval: [ 377 { Dynamic: '{ autocomplete.config.get.apps }' } 378 { Dynamic: '{ autocomplete.config.get.keys $PARAMS[1] }' } 379 ], 380 default: [ 381 { Dynamic: '{ autocomplete.config.get.apps }' } 382 { Dynamic: '{ autocomplete.config.get.keys $PARAMS[1] }' } 383 ] 384 } 385 }] 386 387 autocomplete set test-autocomplete %[{ 388 Flags: [ "111", "222", "333", "444" ] 389 FlagValues: { 390 "111": [ 391 { Dynamic: %({ out aaa\nbbb\nccc\n$PARAMS }) } 392 { Dynamic: %({ out ddd\neee\nfff\n$PARAMS }) } 393 ], 394 "222": [ 395 { Dynamic: %({ out ggg\nhhh\niii\n$PARAMS }) } 396 { Dynamic: %({ out jjj\nkkk\nlll\n$PARAMS }) } 397 ], 398 "333": [ 399 { Dynamic: %({ out mmm\nnnn\nooo\n$PARAMS }) } 400 { Dynamic: %({ out ppp\nqqq\nrrr\n$PARAMS }) } 401 ], 402 "444": [ 403 { Dynamic: %({ out sss\nttt\nuuu\n$PARAMS }) } 404 { Dynamic: %({ out vvv\nwww\nxxx\n$PARAMS }) } 405 ] 406 } 407 }] 408 409 autocomplete set !config %[ 410 { Dynamic: '{ autocomplete.config.get.apps }' } 411 { Dynamic: '{ autocomplete.config.get.keys $PARAMS[0] }' } 412 ] 413 414 415 autocomplete set event %[{ 416 Dynamic: '{ 417 runtime --events \ 418 -> formap k v { out $k } 419 }' 420 }] 421 422 autocomplete set !event %[ 423 { 424 Dynamic: '{ 425 runtime --events \ 426 -> formap k v { out $k } \ 427 -> msort 428 }' 429 }, 430 { 431 Dynamic: '{ 432 runtime: --events \ 433 -> [ $ARGS[1] ] \ 434 -> formap k v { out $k } \ 435 -> msort 436 }' 437 } 438 ] 439 440 private autocomplete.alias { 441 # Returns a map of all alises and the code they execute 442 443 runtime --aliases \ 444 -> formap --jmap name value { $name } { out @value } 445 } 446 447 test unit private autocomplete.alias %{ 448 StdoutRegex: jobs 449 StdoutType: json 450 StdoutGreaterThan: 1 451 StdoutIsMap: true 452 } 453 454 autocomplete set !alias %[{ 455 DynamicDesc: %({ autocomplete.alias }) 456 ListView: true 457 }] 458 459 private autocomplete.functions { 460 # Returns a map of all murex public functions 461 runtime --functions -> formap --jmap k v { $k } { out $v[summary] } 462 } 463 464 test unit private autocomplete.functions %{ 465 PreBlock: %({ 466 function unit.test.autocomplete.functions { 467 out "This is only a dummy function for testing" 468 } 469 }) 470 PostBlock: %({ !function unit.test.autocomplete.functions }) 471 StdoutRegex: unit.test.autocomplete.functions 472 StdoutType: json 473 StdoutIsMap: true 474 StdoutGreaterThan: 1 475 } 476 477 autocomplete set !function %[{ 478 DynamicDesc: %({ autocomplete.functions }) 479 ListView: true 480 }] 481 482 private autocomplete.privates { 483 # Returns a map of all murex private functions 484 485 runtime --privates \ 486 -> struct-keys 3 \ 487 -> regexp m,/.*?/.*?/, \ 488 -> foreach --jmap private { $private } { 489 runtime --privates \ 490 -> [[ $private/Summary ]] 491 } 492 } 493 494 test unit private autocomplete.privates %{ 495 StdoutType: json 496 StdoutGreaterThan: 1 497 StdoutIsMap: true 498 } 499 500 autocomplete set fexec %[{ 501 DynamicDesc: %({ fexec help }) 502 503 FlagValues: { 504 function: [{ 505 DynamicDesc: %({ autocomplete.functions }) 506 ListView: true 507 }] 508 509 private: [{ 510 DynamicDesc: %({ autocomplete.privates }) 511 ListView: true 512 }] 513 514 builtin: [{ 515 DynamicDesc: %({ autocomplete.builtins }) 516 ListView: true 517 }] 518 } 519 }] 520 521 private autocomplete.builtins { 522 # Returns a map of all murex builtins 523 runtime --builtins \ 524 -> foreach --jmap builtin { $builtin } { 525 fexec <!null> builtin murex-docs --summary $builtin \ 526 || fexec builtin murex-docs --summary parser/$builtin 527 } 528 } 529 530 test unit private autocomplete.builtins %{ 531 StdoutType: json 532 StdoutGreaterThan: 1 533 StdoutIsMap: true 534 } 535 536 autocomplete: set autocomplete %[{ 537 Flags: [ get set ] 538 FlagValues: { 539 get: [{ 540 Dynamic: '{ 541 runtime --autocomplete \ 542 -> formap cmd ! { out $cmd } \ 543 -> cast str 544 }' 545 }] 546 } 547 }] 548 549 autocomplete: set debug %[{ 550 Flags: [ on off ] 551 }] 552 553 autocomplete: set murex-package %[{ 554 FlagsDesc: { 555 install: "Installs a package from a user defined URI" 556 remove: "Removes an installed package from disk" 557 update: "Updates all installed packages" 558 import: "Import packages described in a backup package DB from user defined URI or local path" 559 enable: "Enables a previously disabled package or module" 560 disable: "Disables a previously enabled package or module" 561 reload: "Reloads all enabled modules" 562 status: "Returns the version status of locally installed packages" 563 list: "Returns a list of indexed packages/modules (eg what's enabled or disabled)" 564 new: "A wizard to help with creating a new package" 565 git: "Run `git` against a package" 566 cd: "Changes working directory to a package's install location" 567 } 568 FlagValues: { 569 import: [{ 570 IncFiles: true 571 }] 572 remove: [{ 573 "Dynamic": %({ murex-package list packages }) 574 }] 575 enable: [{ 576 DynamicDesc: %({ murex-package list disabled }) 577 ListView: true 578 AutoBranch: true 579 }] 580 disable: [{ 581 DynamicDesc: %({ murex-package list enabled }) 582 ListView: true 583 AutoBranch: true 584 }] 585 list: [{ 586 Flags: [ enabled, disabled, loaded, not-loaded, packages ] 587 }] 588 git: [ 589 { 590 Dynamic: %({ murex-package list packages }) 591 } 592 { 593 ImportCompletion: git 594 } 595 ] 596 cd: [{ 597 Dynamic: %({ murex-package list packages }) 598 }] 599 } 600 }] 601 602 alias builtins=runtime --builtins 603 604 private test.alias.builtins { 605 # Wrapper function around the alias for `builtins` for unit testing 606 builtins 607 } 608 609 test unit private test.alias.builtins %{ 610 StdoutType: json 611 StdoutGreaterThan: 1 612 StdoutIsArray: true 613 } 614 615 private autocomplete.aliases.and.builtins { 616 # Returns a list of aliases and builtins 617 cast str 618 runtime --aliases -> formap k ! { out $k } -> cast str 619 builtins -> format str 620 } 621 622 test unit private autocomplete.aliases.and.builtins %{ 623 StdoutType: str 624 StdoutGreaterThan: 1 625 StdoutIsArray: true 626 } 627 628 autocomplete set summary %[{ 629 IncExePath: true 630 Dynamic: %({ autocomplete.aliases.and.builtins }) 631 }] 632 633 config eval shell safe-commands { 634 -> alter --merge / %[ builtins jobs ] 635 } 636 637 function sprintf { 638 # This is a wrapper around the OS's default `printf`, replacing the now deprecated builtin of the same name 639 -> set params 640 switch { 641 case { $params -> ! } { err "No parameters passed via STDIN" } 642 case { $ARGS[1]-> ! } { err "No string supplied to print" } 643 catch { 644 printf "$ARGS[1]\n" @params 645 } 646 } 647 } 648 649 summary docgen "Document generator for murex development" 650 651 autocomplete set docgen %[ 652 { 653 AllowMultiple: true 654 Optional: true 655 FlagsDesc: { 656 -panic: "Write a stack trace on error" 657 -readonly: "Don't write output to disk. Use this to test the config" 658 -verbose: "Verbose output (all log messages inc warnings)" 659 -version: "Output docgen version number and exit" 660 -warning: "Display warning messages (will also return a non-zero exit status if warnings found)" 661 } 662 } 663 { 664 FlagsDesc: { 665 -config: "Location of the base docgen config file" 666 } 667 668 FlagValues: { 669 -config: [{ 670 IncFiles: true 671 }] 672 } 673 } 674 ] 675 676 config define open image %{ 677 Description: "Which mode to render images to the terminal" 678 DataType: str 679 Default: auto 680 Options: [ auto compatible mxtty kitty iterm terminology sixel ] 681 } 682 683 openagent set image { 684 $ARGS[1] -> set file 685 config get open image -> set mode 686 687 if { = mode==`auto` } { 688 switch { 689 case { $TMUX } { set mode=compatible } 690 case { $MXTTY } { set mode=mxtty } 691 case { $ITERM_PROFILE } { set mode=iterm } 692 case { $TERM_PROGRAM == "iTerm.app" } { set mode=iterm } 693 case { $KITTY_WINDOW_ID } { set mode=kitty } 694 case { $TERM == "xterm-kitty" } { set mode=kitty } 695 case { $TERMINOLOGY } { set mode=terminology } 696 catch { set mode=compatible } 697 } 698 } 699 700 # If Kitty but running inside a screen / tmux session, fallback to compatible. 701 # We do this because tmux doesn't support reporting screen sizes via the TIOCGWINSZ ioctl. 702 if { and { = mode==`kitty` } { = TERM==`screen` } } { 703 set mode=compatible 704 } 705 706 switch $mode { 707 case compatible { 708 open-image $file 709 } 710 711 case mxtty { 712 if { $SSH_TTY } { 713 $json = %{ Base64: ${base64 -i $file -o -} } 714 } else { 715 $json = %{ Filename: $file } 716 } 717 out "{ESC}_insert;image;$(json){ESC}\\" 718 } 719 720 case kitty { 721 try { 722 kitty icat $file 723 } 724 catch { 725 err "Error running `kitty`. Please check `kitty` is installed." 726 } 727 } 728 729 case iterm { 730 if { $TERM =~ '^(screen|tmux)' } then { 731 if { ${tmux show -gw allow-passthrough} == "allow-passthrough on" } then { 732 osc = '{ESC}Ptmux;{ESC}{ESC}]' 733 st = '{BELL}{ESC}\' 734 } else { 735 open-image $file 736 break switch 737 } 738 } else { 739 osc = '{ESC}]' 740 st = '{BELL}' 741 } 742 743 out "$(osc)1337;File=inline=1:${base64 -i $file -o -}$(st)" 744 } 745 746 case terminology { 747 try { 748 tycat -c $file 749 } 750 catch { 751 err "Error running `tycat`. Please check `terminology` is installed." 752 } 753 } 754 755 case sixel { 756 try { 757 img2sixel $file 758 } 759 catch { 760 err "Error running `img2sixel`. Please check `libsixel` is installed." 761 } 762 } 763 764 catch { 765 out "Invalid rendering method. Please define in `config set open image` - 'auto' is recommended." 766 } 767 } 768 } 769 770 private autocomplete.openagents { 771 runtime --open-agents \ 772 -> formap k ! { out $k } \ 773 -> cast str 774 } 775 776 autocomplete set openagent %[{ 777 Flags: [ get, set ] 778 FlagValues: { 779 get: [{ 780 Dynamic: %({ autocomplete.openagents }) 781 }] 782 } 783 }] 784 785 autocomplete set !openagent %[ 786 { 787 Dynamic: %({ autocomplete.openagents }) 788 } 789 ] 790 791 private autocomplete.fid-kill { 792 # Returns a 2D array FIDs 793 fid-list --jsonl -> [ FID Command Parameters ] 794 } 795 796 test unit private autocomplete.fid-kill %{ 797 StdoutRegex: %(^\["FID","Command","Parameters"\]\n.*(\["[0-9]+",")) 798 StdoutType: jsonl 799 ExitNum: 0 800 StdoutGreaterThan: 1 801 } 802 803 autocomplete: set fid-kill %[{ 804 DynamicDesc: '{ autocomplete.fid-kill }' 805 ListView: true 806 AllowMultiple: true 807 }] 808 809 autocomplete set bg %[{ 810 DynamicDesc: '{ fid-list --stopped }' 811 ListView: true 812 }] 813 814 autocomplete set fg %[{ 815 DynamicDesc: '{ 816 fid-list --background \ 817 -> alter -m / ${ fid-list --stopped } 818 }' 819 ListView: true 820 }]