sasjs / cli

Command line interface for creating, compiling, and building SAS® projects
https://cli.sasjs.io
MIT License
37 stars 5 forks source link

sasjs request - enable `--log` and `--output` flags #957

Closed allanbowe closed 2 years ago

allanbowe commented 3 years ago

Currently when running sasjs request and the SAS program does not return a valid JSON response, the following appears in the console:

 ERROR  An error occurred while executing the request.
 The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined

Without a log, the above can be very difficult to debug. We should therefore enable a --log (or -l) flag (and print the location of the log in the console output).

The same logic can also be applied to the response json (with a -o or --output flag, same as sasjs job execute.

Functional Testing

The following should work:

  1. create two test services using SAS Studio, eg:
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
%inc mc;
filename ft15f001 temp;
parmcards4;
  %webout(OPEN)
  data fish;
    set sashelp.fish;
  run;
  %webout(OBJ,fish)
  %webout(CLOSE)
;;;;
%mp_createwebservice(path=/Public/app/adapter/test,name=fish)
parmcards4;
  %abort;
;;;;
%mp_createwebservice(path=/Public/app/adapter/test,name=err)
  1. Execute the following command:
sasjs request /Public/app/adapter/test/fish

Expected:

  1. Execute the following command:
    sasjs request /Public/app/adapter/test/err

Expected:

  1. Execute the following command:
    sasjs request /Public/app/adapter/test/err -l ./mylog.txt

Expected:

  1. Execute the following command:
sasjs request /Public/app/adapter/test/fish -o ./data.json

Expected:

ghost commented 2 years ago

:tada: This issue has been resolved in version 3.5.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: