vscode-ibmi icon indicating copy to clipboard operation
vscode-ibmi copied to clipboard

Pase environment variables

Open worksofliam opened this issue 2 years ago • 9 comments

Changes

Currently, variables are only replaced before the command is executed. This PR adds local variables as environment variables for pase Actions.

Implements #896

Sample

// action
        {
            "type": "member",
            "extensions": [
                "GLOBAL"
            ],
            "environment": "pase",
            "name": "Testing envvar",
            "command": "echo \"$CURLIB $USERNAME $LIBLC\""
        }
# result
Current library: LIAMA
Library list: SAMPLE QDEVTOOLS
Commands:
		echo "$CURLIB $USERNAME $LIBLC"

LIAMA linux QDEVTOOLS,SAMPLE

To do

  • [ ] Acceptance testing
  • [ ] Docs updated

Checklist

  • [x] have tested my change
  • [ ] updated relevant documentation
  • [ ] Remove any/all console.logs I added
  • [ ] eslint is not complaining
  • [ ] have added myself to the contributors' list in CONTRIBUTING.md
  • [x] for feature PRs: PR only includes one feature enhancement.

worksofliam avatar Oct 09 '22 14:10 worksofliam

@Wright4i @chrjorgensen Any chance either of you could test this out for me?

worksofliam avatar Oct 09 '22 14:10 worksofliam

@worksofliam sure thing. I'll test it tomorrow morning!

Wright4i avatar Oct 09 '22 18:10 Wright4i

Working as expected on my end!

Wright4i avatar Oct 10 '22 21:10 Wright4i

@worksofliam I am about to test this - and had a thought about referencing the variables in the command: It may not be obvious that any variable should be referenced as $VAR when the action screen shows &VAR... Maybe an implicit conversion could be done so the user can specify &VAR as usual and this will be converted to $VAR when sent to PASE?

chrjorgensen avatar Oct 11 '22 06:10 chrjorgensen

@worksofliam It also works for my part... however, I see this after saving an ILE action:

/home/NCCJ/Develop/ServiceCommander-IBMi/: /QOpenSys/usr/bin/qsh
liblist -d QGPL QTEMP SYSTEK NCBLIB;liblist -c NCCJ;liblist -a NCCJ NMPAPI GSMTEXT NCCJTESTÅ CHKIBMPTF NCCJTESTÆ NCCJA QGPL QTEMP;system  "DSPFFD FILE(*LIBL/ILES.EOL":) OUTPUT(*OUTFILE) OUTFILE(ILEDITOR/RILE514664)"; if [[ $? -ne 0 ]]; then exit 1; fi
{
    "code": 2,
    "signal": null,
    "stdout": "",
    "stderr": "qsh: 001-0050 Syntax error on line 1: token \")\" not expected."
}

/home/NCCJ/Develop/ServiceCommander-IBMi/: LC_ALL=EN_US.UTF-8 system "call QSYS/QZDFMDB2 PARM('-d' '-i' '-t')"
SELECT * FROM ILEDITOR.RILE514664
{
    "code": 4,
    "signal": null,
    "stdout": "DB2>\n  ?>\n\n **** CLI ERROR *****\n         SQLSTATE: 42704\nNATIVE ERROR CODE: -204\nRILE514664 in ILEDITOR type *FILE not found.",
    "stderr": ""
}

The strange part is this:

DSPFFD FILE(*LIBL/ILES.EOL":) OUTPUT(*OUTFILE) OUTFILE(ILEDITOR/RILE514664)

Maybe unrelated and a faulty config in my instance, but nevertheless...?

chrjorgensen avatar Oct 11 '22 07:10 chrjorgensen

@chrjorgensen i believe that issue is coming from the RPGLE language tools extension and will be fixed in the next release for that (as I just fixed it).

I assume you are still able to save and compile actions like normal?

worksofliam avatar Oct 11 '22 12:10 worksofliam

@chrjorgensen

It may not be obvious that any variable should be referenced as $VAR when the action screen shows &VAR

The user will still be able to use &MYVAR and that's how we will keep recommending it on the UI (due to a magnitude of reasons). The ability to use the environment variables is something we will document but not mention on the UI yet.

This PR is really to enable the programs that are being called to be able to access these variables as well, not so much from the Action command.

worksofliam avatar Oct 11 '22 12:10 worksofliam

@worksofliam

I assume you are still able to save and compile actions like normal?

Yes, no problem in saving actions - only this "error" in the output screen, when saving an ILE action.

chrjorgensen avatar Oct 11 '22 13:10 chrjorgensen

@chrjorgensen I am going to look into that as a separate issue today. Thanks!

worksofliam avatar Oct 11 '22 13:10 worksofliam

@halcyon-tech/core Some further cleanup on this PR today. Any chance we could do some further testing?

Updated docs page here: https://halcyon-tech.github.io/docs/#/pages/developing/local/getting-started?id=pase-environment-variables

worksofliam avatar Dec 08 '22 20:12 worksofliam

I've done further testing and all existing functionality works as expected and new functionality works as expected also.

worksofliam avatar Dec 08 '22 21:12 worksofliam