Comments (10)
IPython uses an exclamation mark to prefix a shell command.
@eliangcs , that is certainly better, I'd rather introduce new command sh
or shell
instead of explanation mark which could take unquoted
, squoted
or dquoted
string as an argument... I think it would be more transparent that way ...
The example would become:
shell echo 'some string value' | post example.com/person/1 | shell grep "abc" | post /upload
Edit: As I think about it, the explanation mark is good as well..
from http-prompt.
I'm thinking of doing what xonsh does -- we try to parse the command as an HTTP Prompt command first. If it failed, we execute it like a shell command. So users can pipe to httpie or shell anyway they want:
echo 'some string value' | post example.com/person/1 | grep "abc" | post /upload
This is basically re-implementing a shell in HTTP Prompt. I guess it won't be hard to do but will require some effort to change the code structure as I did not anticipate this requirement in the beginning of development.
from http-prompt.
Can you add support for <<< ? this works
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 252
Content-Type: application/json
Date: Wed, 13 Mar 2019 07:22:56 GMT
Server: nginx
{
"args": {},
"data": "raw payload\n",
"files": {},
"form": {},
"headers": {
"Accept": "application/json, /",
"Accept-Encoding": "gzip, deflate",
"Content-Length": "12",
"Content-Type": "application/json",
"Host": "httpbin.org",
"User-Agent": "HTTPie/1.0.2"
},
"json": null,
"url": "https://httpbin.org/post"
}
http httpbin.org/post <<< 'raw payload'
Credit:
henrik242 commented Jan 27, 2017
You can also use http httpbin.org/post <<< 'raw payload'
from http-prompt.
The feature has been added to HTTPie (--raw
option, https://github.com/httpie/httpie/tree/master/docs#request-data-via---raw). It will be made available for HTTP Prompt for the next HTTPie release (soon).
from http-prompt.
we try to parse the command as an HTTP Prompt command first. If it failed, we execute it like a shell command.
@eliangcs , that would make http-prompt
quite flexible. I've positive viewpoint on this idea.
but will require some effort to change the code structure
It'd introduce major changes to lexer
/ grammar
definitions. I think, it would need quite a lot of work.
Edit: Maybe, could you review the #74 PR first so I know that I'm on good road? It doesn't need to be merged now. I'd try to make changes in order to support "fallback to shell command" feature which you've introduced... Or do you want to make the major changes by yourself, @eliangcs ?
from http-prompt.
@fogine Sure, I'll start review #74 soon when I have time.
Executing shell commands is easy, but I'm not sure how to deal with the lexer. How do you implement a lexer that is compatible with both shell and HTTP Prompt syntax?
from http-prompt.
How do you implement a lexer that is compatible with both shell and HTTP Prompt syntax?
@eliangcs , I haven't fully thought this through yet however currently I think of defining BashLexer
as fallback when there is no match for any of the main http-prompt lexer definitions (which I think is possible).
Downside of this is that we would basically lose "SyntaxError" highlighting style which would be replaced by bash's Text
style.
The same issue described above applies for command execution - that we'll have to execute every invalid command as bash command which can lead to unexpected behavior (potentially dangerous)... won't we?
from http-prompt.
@fogine I think you're right. Executing any invalid command as a bash command is unpredictable and dangerous. Or we can try IPython's approach. IPython uses an exclamation mark to prefix a shell command. So the previous example becomes:
!echo 'some string value' | post example.com/person/1 | !grep "abc" | post /upload
from http-prompt.
So, do we give the explanation mark a go, @eliangcs ?
I haven't come with better idea so I'd implement it.
from http-prompt.
@fogine yes, feel free to do this 👍
from http-prompt.
Related Issues (20)
- Support Tab completion for files when in prompt mode?
- --verbose Doesn't show request headers
- Any chance to port to prompt_toolkit 3? HOT 7
- Recursive mode & more detailed`ls` HOT 1
- change shortcut for autocomplete?
- Video Interview for v2.1.0 OpenAPI Support
- Preview request? HOT 2
- swagger yaml issue
- Bug: OpenAPI schemas give wrong completion when the root of the API is a path relative to the domain
- Not performing requests on Windows
- http-prompt producing different 'data' than httpie
- Visualize tree structure HOT 2
- Support for setting variables based on response data
- The command line param --auth is showed as url
- The command line param -v show the version but launch the cli HOT 1
- how to remove pager? HOT 2
- Investigate increasing Maintainer Productivity with Pull Requests Environments
- Cookies auto setting invalid.
- An error occurs during installation
- PyOpenSSLContext has no attribute get_ciphers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http-prompt.