Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
recurls
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
recurls
Commits
ec0bf12b
Commit
ec0bf12b
authored
Apr 05, 2023
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli: With click allow to fetch any URL
parent
15719a5f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
setup.py
setup.py
+2
-1
src/recurlests/cli.py
src/recurlests/cli.py
+20
-2
No files found.
setup.py
View file @
ec0bf12b
...
...
@@ -42,6 +42,7 @@ setup(
license
=
'GPLv3+ with wide exception for FOSS'
,
install_requires
=
[
'requests'
,
# for the great CaseInsensitiveDict
'click'
,
# easy cli
],
zip_safe
=
True
,
python_requires
=
">=3.5"
,
...
...
@@ -49,7 +50,7 @@ setup(
package_dir
=
{
""
:
"src"
},
entry_points
=
{
'console_scripts'
:
[
'recurl = recurlests.cli:recurl'
,
'recurl = recurlests.cli:r
unR
ecurl'
,
]
},
)
src/recurlests/cli.py
View file @
ec0bf12b
import
click
from
pprint
import
pprint
from
.
import
recurlests
def
recurl
():
@
click
.
command
(
short_help
=
"Runs curl's wrapper recurl"
)
@
click
.
option
(
'--headers/--no-headers'
,
help
=
"Shows response headers"
,
default
=
False
,
show_default
=
True
)
@
click
.
option
(
'--output/--no-output'
,
help
=
"Shows the output"
,
default
=
False
,
show_default
=
True
)
@
click
.
argument
(
"url"
)
def
runRecurl
(
headers
,
output
,
url
):
mimikra
=
recurlests
.
Recurlests
()
mimikra
.
get
(
'https://www.nexedi.com/'
)
response
=
mimikra
.
get
(
url
)
print
(
'Effective HTTP version:'
,
response
.
effective_http_version
)
print
(
'Response status code:'
,
response
.
status_code
)
print
(
'Response status:'
,
response
.
ok
and
"ok"
or
"error"
)
print
(
'Response content type:'
,
response
.
content_type
)
print
(
'Response elapsed:'
,
response
.
elapsed
)
print
(
'Response effective url:'
,
response
.
url_effective
)
if
headers
:
print
(
'Reponse headers:'
)
pprint
(
dict
(
response
.
headers
))
if
output
:
print
(
'Output:'
)
print
(
response
.
text
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment