Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
O
oh-my-fish
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
nanahira
oh-my-fish
Commits
bb1d149e
Commit
bb1d149e
authored
Nov 26, 2014
by
Roman Inflianskas
Committed by
Bruno Pinto
Nov 28, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dpaste] Add time options: 1, onetime, 2, twotimes
parent
36aa069f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
18 deletions
+35
-18
plugins/dpaste/dpaste.fish
plugins/dpaste/dpaste.fish
+19
-9
plugins/dpaste/tests/test_dpaste.fish
plugins/dpaste/tests/test_dpaste.fish
+16
-9
No files found.
plugins/dpaste/dpaste.fish
View file @
bb1d149e
#!/usr/bin/env fish
# vim: ai ts=2 sw=2 et sts=2
# Just a dpaste (https://github.com/bartTC/dpaste) wrapper for fish-shell
# Just a dpaste (https://github.com/bartTC/dpaste) wrapper for fish-shell
# Roman Inflianskas (rominf) <infroma@gmail.com>
# Roman Inflianskas (rominf) <infroma@gmail.com>
# Based on fish-sprunge plugin:
# Based on fish-sprunge plugin:
...
@@ -6,27 +10,33 @@
...
@@ -6,27 +10,33 @@
# Based on oh-my-zsh's sprunge plugin
# Based on oh-my-zsh's sprunge plugin
set __dpaste_expires_choises '(onetime|
never|hour|week|month
)'
set __dpaste_expires_choises '(onetime|
1|twotimes|2|hour|week|month|never
)'
function __dpaste_set_defaults
function __dpaste_set_defaults
if [ -z $dpaste_keyword ]
set -g __dpaste_url_dpaste_de 'https://dpaste.de/api/?format=url'
set -g dpaste_keyword 'content'
set -q dpaste_keyword; or set -g dpaste_keyword 'content'
end
set -q dpaste_url; or set -g dpaste_url $__dpaste_url_dpaste_de
if [ -z $dpaste_url ]
set -g dpaste_url 'https://dpaste.de/api/?format=url'
end
set -g __dpaste_send_url $dpaste_url
set -g __dpaste_send_url $dpaste_url
end
end
function __dpaste_send
function __dpaste_send
curl -F "$dpaste_keyword=<-" $__dpaste_send_url
function curl
command curl --silent $argv
end
curl -F "$dpaste_keyword=<-" $__dpaste_send_url | read -l url
if [ $__dpaste_eat_once = 1 ]
curl $url >/dev/null
end
echo $url
end
end
function __dpaste_parse_expires
function __dpaste_parse_expires
set expires_spec "-t $__dpaste_expires_choises"
set expires_spec "-t $__dpaste_expires_choises"
set expires (echo $argv | sed -E "s/.*$expires_spec.*/\1/")
set expires (echo $argv | sed -E "s/.*$expires_spec.*/\1/")
if [ -z (echo $expires | sed -E "s/$__dpaste_expires_choises//") ]
if [ -z (echo $expires | sed -E "s/$__dpaste_expires_choises//") ]
set expires (echo $expires | sed 's/hour/3600/' | sed 's/week/604800/' | sed 's/month/2592000/')
echo $expires | grep -qE '(onetime|1)'; set -g __dpaste_eat_once (and echo 1; or echo 0)
set expires (echo $expires | sed -E 's/(1|2|twotimes)/onetime/;s/hour/3600/;s/week/604800/;s/month/2592000/')
set __dpaste_send_url "$__dpaste_send_url&expires=$expires"
set __dpaste_send_url "$__dpaste_send_url&expires=$expires"
end
end
echo $argv | sed -E "s/$expires_spec//" | xargs
echo $argv | sed -E "s/$expires_spec//" | xargs
...
...
plugins/dpaste/tests/test_dpaste.fish
View file @
bb1d149e
...
@@ -21,9 +21,6 @@ end
...
@@ -21,9 +21,6 @@ end
function test_dpaste_system
function test_dpaste_system
set url (eval $argv[1])/raw
set url (eval $argv[1])/raw
# everything is correct:
# one time snippets are available twice if you use curl
curl_and_check $url (echo_text)
curl_and_check $url (echo_text)
curl_and_check $url (echo_text)
# now it shouldn't be available
# now it shouldn't be available
curl_and_fail $url
curl_and_fail $url
...
@@ -44,20 +41,30 @@ function dpaste_teardown
...
@@ -44,20 +41,30 @@ function dpaste_teardown
end
end
function suite_dpaste
function suite_dpaste
function setup
function setup
__dpaste_set_defaults
__dpaste_set_defaults
set -g __dpaste_send_url $__dpaste_url_dpaste_de
end
end
function test_dpaste_parse_expires
function test_dpaste_parse_expires
assert_equal text (__dpaste_parse_expires text)
assert_equal text (__dpaste_parse_expires text)
assert_equal "https://dpaste.de/api/?format=url" $__dpaste_send_url
assert_equal "https://dpaste.de/api/?format=url" $__dpaste_send_url
set -g __dpaste_send_url $dpaste_url
end
assert_equal text (__dpaste_parse_expires -t never text)
assert_equal "https://dpaste.de/api/?format=url&expires=never" $__dpaste_send_url
function test_dpaste_parse_expires_1
set -g __dpaste_send_url $dpaste_url
assert_equal text (__dpaste_parse_expires -t 1 text)
assert_equal "https://dpaste.de/api/?format=url&expires=onetime" $__dpaste_send_url
end
function test_dpaste_parse_expires_hour
assert_equal text (__dpaste_parse_expires -t hour text)
assert_equal text (__dpaste_parse_expires -t hour text)
assert_equal "https://dpaste.de/api/?format=url&expires=3600" $__dpaste_send_url
assert_equal "https://dpaste.de/api/?format=url&expires=3600" $__dpaste_send_url
set -g __dpaste_send_url $dpaste_url
end
function test_dpaste_parse_expires_never
assert_equal text (__dpaste_parse_expires -t never text)
assert_equal "https://dpaste.de/api/?format=url&expires=never" $__dpaste_send_url
end
end
function test_dpaste_system_file_redirect
function test_dpaste_system_file_redirect
...
@@ -87,6 +94,7 @@ function suite_dpaste
...
@@ -87,6 +94,7 @@ function suite_dpaste
end
end
test_dpaste_system dpaste_text
test_dpaste_system dpaste_text
end
end
end
end
...
@@ -99,4 +107,3 @@ if not set -q tank_running
...
@@ -99,4 +107,3 @@ if not set -q tank_running
tank_run
tank_run
dpaste_teardown
dpaste_teardown
end
end
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