Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 08b2ad7f
authored
Jun 27, 2015
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cli
1 parent
eaa62184
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
src/actions.js
surfer.js
src/actions.js
0 → 100644
View file @
08b2ad7
'use strict'
;
exports
.
put
=
put
;
exports
.
get
=
get
;
exports
.
del
=
del
;
var
superagent
=
require
(
'superagent'
),
path
=
require
(
'path'
);
var
server
=
'http://localhost:3000/api/files/'
;
function
put
(
filePath
)
{
var
relativeFilePath
=
path
.
resolve
(
filePath
).
slice
(
process
.
cwd
().
length
+
1
);
superagent
.
put
(
server
+
relativeFilePath
).
attach
(
'file'
,
filePath
).
end
(
function
(
error
,
result
)
{
if
(
error
)
return
console
.
log
(
'Failed'
,
result
?
result
.
body
:
error
);
console
.
log
(
'Success'
,
result
.
body
);
});
}
function
get
(
filePath
)
{
var
relativeFilePath
=
path
.
resolve
(
filePath
).
slice
(
process
.
cwd
().
length
+
1
);
superagent
.
get
(
server
+
relativeFilePath
).
end
(
function
(
error
,
result
)
{
if
(
error
)
return
console
.
log
(
'Failed'
,
result
?
result
.
body
:
error
);
console
.
log
(
'Success'
,
result
.
body
);
});
}
function
del
(
filePath
)
{
var
relativeFilePath
=
path
.
resolve
(
filePath
).
slice
(
process
.
cwd
().
length
+
1
);
superagent
.
del
(
server
+
relativeFilePath
).
end
(
function
(
error
,
result
)
{
if
(
error
)
return
console
.
log
(
'Failed'
,
result
?
result
.
body
:
error
);
console
.
log
(
'Success'
,
result
.
body
);
});
}
surfer.js
0 → 100755
View file @
08b2ad7
#!/usr/bin/env node
'use strict'
;
var
program
=
require
(
'commander'
),
actions
=
require
(
'./src/actions'
);
// Allow self signed certs!
process
.
env
.
NODE_TLS_REJECT_UNAUTHORIZED
=
'0'
;
program
.
version
(
'0.1.0'
);
program
.
command
(
'put'
)
.
description
(
'Put a file'
)
.
action
(
actions
.
put
);
program
.
command
(
'get'
)
.
description
(
'Get a file or directory'
)
.
action
(
actions
.
get
);
program
.
command
(
'del'
)
.
description
(
'Delete a file'
)
.
action
(
actions
.
del
);
program
.
parse
(
process
.
argv
);
Write
Preview
Markdown
is supported
Attach a file
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 post a comment