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

feat: add curl config #115

Merged
merged 5 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/curl/0.1.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 yanming zhang <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
34 changes: 34 additions & 0 deletions packages/curl/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
package_name: "curl"
package_title: "curl Package"
package_desc: "A package to get curl code snippets"
package_version: "0.1.0"
package_author: "yanming zhang"
package_repo: "https://github.com/zhangymPerson/espanso-package-curl"
---
An package to get curl command code snippets

For more information about espanso packages, read the [documentation](https://espanso.org/docs/).

## Usage

Available replacements:

| replacement | description | output |
| ---------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------- |
| `:curl:` | Get curl command example | `curl --request GET http://example.com` |
| `:curlget:` | Get curl command example with query string | `curl --request GET http://example.com?key=value` |
| `:curlpost:` | Get curl command example with post | `curl --request POST http://example.com` |
| `:curlput:` | Get curl command example with put | `curl --request PUT http://example.com` |
| `:curldelete:` | Get curl command example with delete | `curl --request DELETE http://example.com` |
| `:curlpatch:` | Get curl command example with patch | `curl --request PATCH http://example.com` |
| `:curlxml:` | Get curl command example with xml | `curl --request POST --header 'Content-Type: application/xml' --data '<key>value</key>' http://example.com` |
| `:curljson:` | Get curl command example with json | `curl --request POST --header 'Content-Type: application/json' --data '{"key":"value"}' http://example.com` |
| `:curldata:` | Get curl command example with data | `curl --request POST --header 'Content-Type: multipart/form-data' --form 'key=value' http://example.com` |
| `:curldownload:` | Get curl command example with download | `curl --request GET --output file.txt http://example.com` |
| `:curlupload:` | Get curl command example with upload | `curl --request POST --form 'file=@/path/to/file' http://example.com` |
| `:curlheader:` | Get curl command example with header | `curl --request GET --header 'X-My-Header: 123' http://example.com` |
| `:curlcookie:` | Get curl command example with cookie | `curl --request GET --cookie 'key=value' http://example.com` |
| `:curlbasic:` | Get curl command example with basic auth | `curl --request GET --user 'username:password' http://example.com` |
| `:curlproxy:` | Get curl command example with proxy | `curl --request GET --proxy http://proxy.example.com:8080 http://example.com` |
| `:curlbearer:` | Get curl command example with bearer auth | `curl --request GET --header 'Authorization: Bearer token' http://example.com` |
7 changes: 7 additions & 0 deletions packages/curl/0.1.0/_manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
author: yanming zhang
description: An package to get curl command code snippets
name: curl
title: curl Package
version: 0.1.0
homepage: "https://github.com/zhangymPerson/espanso-package-curl"
tags: ["curl", "shell", "development"]
53 changes: 53 additions & 0 deletions packages/curl/0.1.0/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# curl package

name: curl
parent: default

matches:
- trigger: ":curl:"
replace: "curl --request GET https://example.com"

- trigger: ":curlget:"
replace: "curl --request GET https://example.com?key=value"

- trigger: ":curlpost:"
replace: "curl --request POST https://example.com"

- trigger: ":curlput:"
replace: "curl --request PUT https://example.com"

- trigger: ":curldelete:"
replace: "curl --request DELETE https://example.com"

- trigger: ":curlpatch:"
replace: "curl --request PATCH https://example.com"

- trigger: ":curldata:"
replace: "curl --request POST --header 'Content-Type: multipart/form-data' --form 'key=value' http://example.com"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for the mix of https: and http:? The former throughout might be safer? I'd be happy to merge if this is addressed (unless there are good reasons not to).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I added the relevant global variables as per your prompt


- trigger: ":curlxml:"
replace: "curl --request POST --header 'Content-Type: application/xml' --data '<key>value</key>' http://example.com"

- trigger: ":curljson:"
replace: 'curl --request POST --header ''Content-Type: application/json'' --data ''{"key":"value"}'' http://example.com'

- trigger: ":curlheader:"
replace: "curl --request GET --header 'X-My-Header: 123' http://example.com"

- trigger: ":curlcookie:"
replace: "curl --request GET --cookie 'key=value' http://example.com"

- trigger: ":curlbasic:"
replace: "curl --request GET --user 'username:password' http://example.com"

- trigger: ":curlbearer:"
replace: "curl --request GET --header 'Authorization: Bearer token' http://example.com"

- trigger: ":curlproxy:"
replace: "curl --request GET --proxy http://proxy.example.com:8080 http://example.com"

- trigger: ":curldownload:"
replace: "curl --request GET --output file.txt http://example.com"

- trigger: ":curlupload:"
replace: "curl --request POST --form 'file=@/path/to/file' http://example.com"