Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode Task to create new packages #36

Open
martindsouza opened this issue Aug 21, 2020 · 11 comments
Open

VSCode Task to create new packages #36

martindsouza opened this issue Aug 21, 2020 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@martindsouza
Copy link
Contributor

Create a new VSCode Task do to the following when run:

Paramater: package_name

Actions:

  • Create two new files package_name.pks and package_name.pkb (note the file name extensions are now in scripts/project-config.sh
  • Load each of the files from the associated templates in the templates folder
  • Rename the package names to package_name

I find I'm doing this over and over again when creating a lot of new packages. It's a minor thing but could help people with new package development.

Notes:

  • Slightly different than snippets in that this will create files
  • Can be expanded for views (or other objects)
@martindsouza martindsouza added the enhancement New feature or request label Aug 21, 2020
@rimblas
Copy link
Contributor

rimblas commented Aug 21, 2020

Ohhh, yes please. I love this

@martindsouza
Copy link
Contributor Author

@rimblas what do you think of just making one task that has two parameters:

  • object_type (ex: view or package to start)
    • Note that package will create the spec and body files
  • object_name

This way we wouldn't need a bunch of tasks. Concern is cluttering up drop down list when multiple projects are open.

@rimblas
Copy link
Contributor

rimblas commented Aug 22, 2020

Yes,that sound reasonable. Although, I don't see view as a burden, meaning the task is not a big time saver.
I would default the type to package if possible.

martindsouza added a commit that referenced this issue Aug 27, 2020
martindsouza added a commit that referenced this issue Aug 27, 2020
@martindsouza
Copy link
Contributor Author

@rimblas this is now in place. Can you please give it a try and provide your feedback?

@martindsouza martindsouza self-assigned this Aug 27, 2020
@vitodcampanelli
Copy link

vitodcampanelli commented Aug 27, 2020

Files get created but I am getting the following error:
Edited: Replace image with shell output.

> Executing task: .vscode/scripts/gen_object.sh view test2 <

sed: invalid option -- 'a'
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
      --debug
                 annotate program execution
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be executed
  --follow-symlinks
                 follow symlinks when processing in place
  -i[SUFFIX], --in-place[=SUFFIX]
                 edit files in place (makes backup if SUFFIX supplied)
  -l N, --line-length=N
                 specify the desired line-wrap length for the `l' command
  --posix
                 disable all GNU extensions.
  -E, -r, --regexp-extended
                 use extended regular expressions in the script
                 (for portability use POSIX -E).
  -s, --separate
                 consider files as separate rather than as a single,
                 continuous long stream.
      --sandbox
                 operate in sandbox mode (disable e/r/w commands).
  -u, --unbuffered
                 load minimal amounts of data from the input files and flush
                 the output buffers more often
  -z, --null-data
                 separate lines by NUL characters
      --help     display this help and exit
      --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
rm: /Users/xyz/GitHub/starter-project-template-2/.vscode/tasks.json-bak: No such file or directory
sed: invalid option -- 'a'
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
      --debug
                 annotate program execution
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be executed
  --follow-symlinks
                 follow symlinks when processing in place
  -i[SUFFIX], --in-place[=SUFFIX]
                 edit files in place (makes backup if SUFFIX supplied)
  -l N, --line-length=N
                 specify the desired line-wrap length for the `l' command
  --posix
                 disable all GNU extensions.
  -E, -r, --regexp-extended
                 use extended regular expressions in the script
                 (for portability use POSIX -E).
  -s, --separate
                 consider files as separate rather than as a single,
                 continuous long stream.
      --sandbox
                 operate in sandbox mode (disable e/r/w commands).
  -u, --unbuffered
                 load minimal amounts of data from the input files and flush
                 the output buffers more often
  -z, --null-data
                 separate lines by NUL characters
      --help     display this help and exit
      --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
rm: /Users/xyz/GitHub/starter-project-template-2/views/test2.sql-bak: No such file or directory
Created: /Users/xyz/GitHub/starter-project-template-2/views/test2.sql

Terminal will be reused by tasks, press any key to close it.

@martindsouza
Copy link
Contributor Author

@vitodcampanelli I think this could be a difference in our versions of sed. Can you please test what happens with this:

sed -i -bak "s/CHANGEME_TASKLABEL/$PROJECT_DIR_FOLDER_NAME/g" $VSCODE_TASK_FILE

@vitodcampanelli
Copy link

vitodcampanelli commented Aug 27, 2020

Edited: Replaced image with terminal output

sed: invalid option -- 'a'
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
      --debug
                 annotate program execution
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be executed
  --follow-symlinks
                 follow symlinks when processing in place
  -i[SUFFIX], --in-place[=SUFFIX]
                 edit files in place (makes backup if SUFFIX supplied)
  -l N, --line-length=N
                 specify the desired line-wrap length for the `l' command
  --posix
                 disable all GNU extensions.
  -E, -r, --regexp-extended
                 use extended regular expressions in the script
                 (for portability use POSIX -E).
  -s, --separate
                 consider files as separate rather than as a single,
                 continuous long stream.
      --sandbox
                 operate in sandbox mode (disable e/r/w commands).
  -u, --unbuffered
                 load minimal amounts of data from the input files and flush
                 the output buffers more often
  -z, --null-data
                 separate lines by NUL characters
      --help     display this help and exit
      --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.

@martindsouza
Copy link
Contributor Author

@vitodcampanelli can you also include the exact command that you ran? Find it odd it's complaining about -a when we don't use that.

@vitodcampanelli
Copy link

@martindsouza Here is the command

sed -i -bak "s/CHANGEME_TASKLABEL/$PROJECT_DIR_FOLDER_NAME/g" $VSCODE_TASK_FILE

@martindsouza
Copy link
Contributor Author

@vitodcampanelli what are the values for $PROJECT_DIR_FOLDER_NAME and $VSCODE_TASK_FILE (want to make sure no special characters in path or spaces

@vitodcampanelli
Copy link

vitodcampanelli commented Aug 27, 2020

Ok when I run the following

# Directory of this file
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "SCRIPT_DIR: " $SCRIPT_DIR

# Load helper
source $SCRIPT_DIR/../../scripts/helper.sh

echo "PROJECT_DIR_FOLDER_NAME: " $PROJECT_DIR_FOLDER_NAME
echo "VSCODE_TASK_FILE: " $VSCODE_TASK_FILE

Output is:

SCRIPT_DIR:  /Users/xyz/GitHub/starter-project-template-2/.vscode/scripts
sed: invalid option -- 'a'
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
      --debug
                 annotate program execution
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be executed
  --follow-symlinks
                 follow symlinks when processing in place
  -i[SUFFIX], --in-place[=SUFFIX]
                 edit files in place (makes backup if SUFFIX supplied)
  -l N, --line-length=N
                 specify the desired line-wrap length for the `l' command
  --posix
                 disable all GNU extensions.
  -E, -r, --regexp-extended
                 use extended regular expressions in the script
                 (for portability use POSIX -E).
  -s, --separate
                 consider files as separate rather than as a single,
                 continuous long stream.
      --sandbox
                 operate in sandbox mode (disable e/r/w commands).
  -u, --unbuffered
                 load minimal amounts of data from the input files and flush
                 the output buffers more often
  -z, --null-data
                 separate lines by NUL characters
      --help     display this help and exit
      --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
rm: /Users/xyz/GitHub/starter-project-template-2/.vscode/tasks.json-bak: No such file or directory
PROJECT_DIR_FOLDER_NAME: 
VSCODE_TASK_FILE: 

Removing the line

source $SCRIPT_DIR/../../scripts/helper.sh

Output has no errors but the variables blank as expected.

SCRIPT_DIR:  /Users/xyz/GitHub/starter-project-template-2/.vscode/scripts
PROJECT_DIR_FOLDER_NAME: 
VSCODE_TASK_FILE: 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants