GitHunt
MS

mshcruz/GAS-Terminal

A spreadsheet that can easily execute functions (called commands) created with Google apps script.

GAS-Terminal

A spreadsheet that can easily execute functions (called commands) created with Google Apps Script. It also supports long-running scripts.

The original spreadsheet is here.

Related article is here.

And an article about long-running support is here.

image

What is this?

This spreadsheet will help you in the following ways.

  • it makes your functions manageable and easy to understand.
  • it allows you to modify execution parameters and to run the functions easily.
  • it allows you to check the execution result log easily.

How to use

1. Copy the original spreadsheet (only once).

Open this spreadsheat, click [File]-[Make a copy], and save it to your Google Drive with a name of your choice. (You must be signed in with a Google account.)

image

2. Open the Script editor

Open the new spreadsheet, click [Tools]-[Script editor].

image

3. Write your code.

In the Script editor, you can write any function you need. You can write it in any source file you like (or in a new file, of course), but do not edit the group of files starting with gas-terminal.

image

Tips

  • To output the log to the result area, use the LogUtils class.
  • A function can have up to five arguments. (All parameters are of type string)
  • If you want to implement a function that runs for a long time, use the LongRun class. (See the bottom of this README)

4. Write the definition of the command

In the Commands sheet, write the command definition that corresponds to the function you wrote.

image

5. Execute the command

In the Terminal sheet, select the command, input parameters, then click the Execute button.

image

6. Authorize the script to run (only once)

The first time you run it, you will see a dialog asking for permission to run the script. Follow the steps below to allow the script to run.

  • Click Continue
    image

  • Select your account (Perhaps it will be a different procedure for signing in.)
    image

  • Click Advanced.
    image

  • Click Go to GAS-Terminal (unsafe).
    image

  • Click Allow.
    image

  • Then click Execute button again.

    Don't worry about the word "unsafe". It's a dialog that all of us face when running our personal scripts.๐Ÿ‘

7. Click Yes and check the result (as shown at the top of this page).

image

If you want to modify this tool by using clasp and TypeScript

  1. Follow the instructions above to copy the original spreadsheet.
  2. Open the Script editor, click Project Settings, copy the Script ID. (We'll use it later)
  3. If you have not installed clasp yet, install clasp, following the official page.
  4. Do the command clasp login, and login with your account. (If you have not done yet)
  5. Clone this repository, and open the cloned project with your IDE.
  6. Open .clasp.json, and replace the scriptId with your Script ID copied above.
  7. You can make any changes you like to the cloned code.
  8. Then do the command clasp push, and it will replace your copied spreadsheet's Apps Script with your code.

Support for long-running scripts

Google Apps Script has the 6 minute execution time limit. This problem is very tricky.
You can solve this problem by using the GAS-Terminal's class LongRun.
Please see the sample function named LongRunTest in Code.ts. You also can run the sample command by select the command named Long-Running Test (Sample) and can execute it.