-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftpd.rb
87 lines (72 loc) · 1.5 KB
/
ftpd.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
$:.unshift "../lib"
$:.unshift "lib"
require 'choice'
port = 21
PROGRAM_VERSION = 4
Choice.options do
#banner "Usage: ftpd.rb [options]"
header ""
header "Specific options:"
option :host do
short '-h'
long '--host=HOST'
desc "The hostname or ip of the host to bind to"
desc "(default 127.0.0.1)"
default '127.0.0.1'
end
option :port do
short '-p'
long '--port=PORT'
desc "The port to listen on (default 21)"
cast Integer
default port
end
option :clients do
short '-c'
long '--clients=NUM'
cast Integer
desc "The number of connections to allow at once (default 5)"
default 5
end
option :protocol do
short '-l'
long '--protocol=PROTOCOL'
desc "The protocol to use (default ftp)"
valid %w[ftp sftp]
default 'ftp'
end
option :yaml_cfg do
long '--config=FILE'
desc 'Load configuration from YAML file'
end
option :sample do
long '--sample'
desc "See a sample YAML config file"
action do
puts "See!"
exit
end
end
option :debug do
short '-d'
long '--debug[=LEVEL]'
desc 'Turn on debugging mode'
end
separator ''
separator 'Common options: '
option :help do
long '--help'
desc 'Show this message'
end
option :version do
short '-v'
long '--version'
desc 'Show version'
action do
puts "ftpd.rb FTP server v#{PROGRAM_VERSION}"
exit
end
end
end
print "Choices: "
puts Choice.choices.inspect