mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tools: add v share file.v
(#17172)
This commit is contained in:
parent
26b9464f51
commit
10261c427f
39
cmd/tools/vshare.v
Normal file
39
cmd/tools/vshare.v
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
import net.http
|
||||||
|
import os
|
||||||
|
import clipboard
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
mut cb := clipboard.new()
|
||||||
|
|
||||||
|
if os.args.len < 3 {
|
||||||
|
eprintln('Please provide a file')
|
||||||
|
exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if os.file_ext(os.args[2]) != '.v' {
|
||||||
|
eprintln('Must be a V source file.')
|
||||||
|
exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !os.is_file(os.args[2]) {
|
||||||
|
eprintln('File not found.')
|
||||||
|
exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
to_send := os.args[2]
|
||||||
|
|
||||||
|
content := os.read_file(to_send) or {
|
||||||
|
eprintln(err)
|
||||||
|
exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
share := http.post_form('https://play.vlang.io/share', {
|
||||||
|
'code': content
|
||||||
|
})!
|
||||||
|
url := 'https://play.vlang.io/p/${share.body}'
|
||||||
|
|
||||||
|
cb.copy(url)
|
||||||
|
println(url)
|
||||||
|
}
|
@ -34,6 +34,7 @@ const (
|
|||||||
'self',
|
'self',
|
||||||
'setup-freetype',
|
'setup-freetype',
|
||||||
'shader',
|
'shader',
|
||||||
|
'share',
|
||||||
'should-compile-all',
|
'should-compile-all',
|
||||||
'symlink',
|
'symlink',
|
||||||
'scan',
|
'scan',
|
||||||
|
@ -19,6 +19,8 @@ Other less frequently used commands supported by V include:
|
|||||||
|
|
||||||
setup-freetype Setup thirdparty freetype on Windows.
|
setup-freetype Setup thirdparty freetype on Windows.
|
||||||
|
|
||||||
|
share Send your code to the V Playground
|
||||||
|
|
||||||
translate Translate C code to V.
|
translate Translate C code to V.
|
||||||
|
|
||||||
tracev Produce a tracing version of the v compiler.
|
tracev Produce a tracing version of the v compiler.
|
||||||
|
4
vlib/v/help/other/share.txt
Normal file
4
vlib/v/help/other/share.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Send your code to the V Playground
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
v share FILE
|
Loading…
Reference in New Issue
Block a user