Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav
eepm
Commits
3c31e9ac
Commit
3c31e9ac
authored
1 year ago
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eget: add initial ipfs support for first arg
parent
aa7d54e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
tools_eget
bin/tools_eget
+50
-0
No files found.
bin/tools_eget
View file @
3c31e9ac
...
...
@@ -176,6 +176,22 @@ is_url()
echo
"
$1
"
|
grep
-q
"^[filehtps]*:/"
}
is_ipfs_hash
()
{
echo
"
$1
"
|
grep
-q
-E
"^Qm[[:alnum:]]{44}$"
}
is_ipfsurl
()
{
is_ipfs_hash
"
$1
"
&&
return
echo
"
$1
"
|
grep
-q
"^ipfs://"
}
cid_from_url
()
{
echo
"
$1
"
|
sed
-e
's|^ipfs://*||'
}
# args: cmd <URL> <options>
# will run cmd <options> <URL>
...
...
@@ -359,6 +375,35 @@ check_url_is_accessible()
test
-f
"
$(
path_from_url
"
$URL
"
)
"
}
elif
is_ipfsurl
"
$1
"
;
then
# put remote content to stdout
scat
()
{
local
URL
=
"
$1
"
a
=
ipfs
cat
"
$(
cid_from_url
"
$URL
"
)
"
}
# download to default name of to $2
sget
()
{
local
URL
=
"
$1
"
if
[
"
$2
"
=
"/dev/stdout"
]
||
[
"
$2
"
=
"-"
]
;
then
scat
"
$URL
"
return
elif
[
-n
"
$2
"
]
;
then
a
=
ipfs get
-o
"
$2
"
"
$(
cid_from_url
"
$URL
"
)
"
return
fi
a
=
ipfs get
"
$(
path_from_url
"
$URL
"
)
"
}
check_url_is_accessible
()
{
local
URL
=
"
$1
"
# TODO: improve me
scat
"
$URL
"
>
/dev/null
}
elif
[
-n
"
$WGET
"
]
;
then
__wget
()
{
...
...
@@ -529,6 +574,11 @@ if echo "$1" | grep -q "^https://github.com/" && \
exit
fi
if
is_ipfsurl
"
$1
"
;
then
[
-n
"
$2
"
]
&&
fatal
"too many args when ipfs://Qm... used: extra '
$2
' arg"
sget
"
$1
"
"
$TARGETFILE
"
exit
fi
# if mask is the second arg
if
[
-n
"
$2
"
]
;
then
...
...
This diff is collapsed.
Click to expand it.
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