From 740a861d04a07a8dcadcaf3cec466ed5cdfb6c89 Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Sat, 10 Aug 2024 15:00:06 -0700 Subject: [PATCH 1/5] chore: add mysql tool Signed-off-by: Taylor Price --- clis/mysql/tool.gpt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 clis/mysql/tool.gpt diff --git a/clis/mysql/tool.gpt b/clis/mysql/tool.gpt new file mode 100644 index 000000000..f5d441ee1 --- /dev/null +++ b/clis/mysql/tool.gpt @@ -0,0 +1,24 @@ +name: mysql +type: context +description: Provides the ability to interact with mysql databases. +share tools: sys.exec +share credential: github.com/gptscript-ai/credential as cli.mysql.password with MYSQL_PWD as env and password as field and "Please enter your mysql user's password:" as message + +#!/bin/bash + +if ! command -v mysql; then + echo "The user does not have the mysql cli installed or it is not available on the PATH." +else + echo "The user has the mysql cli available. Use it to work with mysql." + echo "The following is the help text for the mysql cli. Always execute mysql statements non-interactively from the CLI using one of two options:" + echo '`-e "${SQL_QUERY}"` for single sql statements' + echo "`< /path/to/script.sql` for longer scripts" + echo "" + echo 'The password is pre-set using the `$MYSQL_PWD` environment variable' + + echo "the following text is the help output of the mysql cli:" + echo "```" + mysql --help + echo "```" +fi + From 11261627b4f24f6f2f51a8b71ccaa8c7cabb4d46 Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Sun, 11 Aug 2024 12:19:16 -0700 Subject: [PATCH 2/5] chore: single quote all the things Signed-off-by: Taylor Price --- clis/mysql/tool.gpt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/clis/mysql/tool.gpt b/clis/mysql/tool.gpt index f5d441ee1..5b234c249 100644 --- a/clis/mysql/tool.gpt +++ b/clis/mysql/tool.gpt @@ -7,18 +7,17 @@ share credential: github.com/gptscript-ai/credential as cli.mysql.password with #!/bin/bash if ! command -v mysql; then - echo "The user does not have the mysql cli installed or it is not available on the PATH." + echo 'The user does not have the mysql cli installed or it is not available on the PATH.' else - echo "The user has the mysql cli available. Use it to work with mysql." - echo "The following is the help text for the mysql cli. Always execute mysql statements non-interactively from the CLI using one of two options:" + echo 'The user has the mysql cli available. Use it to work with mysql.' + echo 'Always execute mysql statements non-interactively from the CLI using one of two options:' echo '`-e "${SQL_QUERY}"` for single sql statements' - echo "`< /path/to/script.sql` for longer scripts" - echo "" + echo '`< /path/to/script.sql` for longer scripts' echo 'The password is pre-set using the `$MYSQL_PWD` environment variable' - echo "the following text is the help output of the mysql cli:" - echo "```" + echo 'The following text is the help output of the mysql cli:' + echo '```' mysql --help - echo "```" + echo '```' fi From d0118830699c1f2c4803c9ef6b9a70e6d1c80ae1 Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Sun, 11 Aug 2024 12:24:55 -0700 Subject: [PATCH 3/5] chore: add additional credentials for username and hostname Signed-off-by: Taylor Price --- clis/mysql/tool.gpt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clis/mysql/tool.gpt b/clis/mysql/tool.gpt index 5b234c249..ad00e49ba 100644 --- a/clis/mysql/tool.gpt +++ b/clis/mysql/tool.gpt @@ -2,7 +2,9 @@ name: mysql type: context description: Provides the ability to interact with mysql databases. share tools: sys.exec -share credential: github.com/gptscript-ai/credential as cli.mysql.password with MYSQL_PWD as env and password as field and "Please enter your mysql user's password:" as message +share credentials: github.com/gptscript-ai/credential as cli.mysql.password with MYSQL_PWD as env and password as field and "Please enter your mysql user's password:" as message +share credentials: github.com/gptscript-ai/credential as cli.mysql.username with MYSQL_USER as env and username as field and "Please enter your mysql username:" as message +share credentials: github.com/gptscript-ai/credential as cli.mysql.hostname with MYSQL_HOST as env and hostname as field and "Please enter your mysql hostname/ip:" as message #!/bin/bash @@ -14,6 +16,9 @@ else echo '`-e "${SQL_QUERY}"` for single sql statements' echo '`< /path/to/script.sql` for longer scripts' echo 'The password is pre-set using the `$MYSQL_PWD` environment variable' + echo 'The username is pre-set using the `$MYSQL_USER' environment variable. You can pass that to the cli using `-u ${MYSQL_USER}`' + echo 'The hostname/ip is pre-set using the `$MYSQL_HOST' environment variable. You can pass that to the cli using `-h ${MYSQL_HOST}`' + echo 'The following text is the help output of the mysql cli:' echo '```' From 4dc313d75ccdeb10156018eb14aedfdeefe1a577 Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Sun, 11 Aug 2024 12:27:31 -0700 Subject: [PATCH 4/5] fix: matching backtick Signed-off-by: Taylor Price --- clis/mysql/tool.gpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clis/mysql/tool.gpt b/clis/mysql/tool.gpt index ad00e49ba..900823e7c 100644 --- a/clis/mysql/tool.gpt +++ b/clis/mysql/tool.gpt @@ -16,8 +16,8 @@ else echo '`-e "${SQL_QUERY}"` for single sql statements' echo '`< /path/to/script.sql` for longer scripts' echo 'The password is pre-set using the `$MYSQL_PWD` environment variable' - echo 'The username is pre-set using the `$MYSQL_USER' environment variable. You can pass that to the cli using `-u ${MYSQL_USER}`' - echo 'The hostname/ip is pre-set using the `$MYSQL_HOST' environment variable. You can pass that to the cli using `-h ${MYSQL_HOST}`' + echo 'The username is pre-set using the `$MYSQL_USER` environment variable. You can pass that to the cli using `-u ${MYSQL_USER}`' + echo 'The hostname/ip is pre-set using the `$MYSQL_HOST` environment variable. You can pass that to the cli using `-h ${MYSQL_HOST}`' echo 'The following text is the help output of the mysql cli:' From eac822d4ba628d0982b2259be0f87d4fb4f32b6d Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Sun, 11 Aug 2024 12:32:37 -0700 Subject: [PATCH 5/5] chore: update description to mention the cli used Signed-off-by: Taylor Price --- clis/mysql/tool.gpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clis/mysql/tool.gpt b/clis/mysql/tool.gpt index 900823e7c..8d93582c2 100644 --- a/clis/mysql/tool.gpt +++ b/clis/mysql/tool.gpt @@ -1,6 +1,6 @@ name: mysql type: context -description: Provides the ability to interact with mysql databases. +description: Provides the ability to interact with mysql databases using the mysql cli. share tools: sys.exec share credentials: github.com/gptscript-ai/credential as cli.mysql.password with MYSQL_PWD as env and password as field and "Please enter your mysql user's password:" as message share credentials: github.com/gptscript-ai/credential as cli.mysql.username with MYSQL_USER as env and username as field and "Please enter your mysql username:" as message