@@ -11,12 +11,14 @@ import 'package:shelf_static/shelf_static.dart';
11
11
void main (List <String > args) {
12
12
final parser = _getParser ();
13
13
14
+ String address;
14
15
int port;
15
16
bool logging;
16
17
bool listDirectories;
17
18
18
19
try {
19
20
final result = parser.parse (args);
21
+ address = result['address' ] as String ;
20
22
port = int .parse (result['port' ] as String );
21
23
logging = result['logging' ] as bool ;
22
24
listDirectories = result['list-directories' ] as bool ;
@@ -47,14 +49,16 @@ void main(List<String> args) {
47
49
final handler = pipeline.addHandler (createStaticHandler ('example/files' ,
48
50
defaultDocument: defaultDoc, listDirectories: listDirectories));
49
51
50
- io.serve (handler, 'localhost' , port).then ((server) {
52
+ io.serve (handler, address , port).then ((server) {
51
53
print ('Serving at http://${server .address .host }:${server .port }' );
52
54
});
53
55
}
54
56
55
57
ArgParser _getParser () => ArgParser ()
56
- ..addFlag ('logging' , abbr: 'l' , defaultsTo: true )
57
- ..addOption ('port' , abbr: 'p' , defaultsTo: '8080' )
58
+ ..addFlag ('logging' , abbr: 'l' , defaultsTo: true , help: 'Enable logging' )
59
+ ..addOption ('port' , abbr: 'p' , defaultsTo: '8080' , help: 'Port to listen on' )
60
+ ..addOption ('address' ,
61
+ abbr: 'a' , defaultsTo: 'localhost' , help: 'Address to listen on' )
58
62
..addFlag ('list-directories' ,
59
63
abbr: 'f' ,
60
64
negatable: false ,
0 commit comments