ggdgsdbsdbbb / cli.v
37 lines · 33 sloc · 908 bytes · bed64285555e6c9bf5ebf34b7538e1da67e926b2
Raw
1// Copyright (c) 2020-2021 Alexander Medvednikov. All rights reserved.
2// Use of this source code is governed by a GPL license that can be found in the LICENSE file.
3module main
4
5import os
6
7pub fn (mut app App) command_fetcher() ! {
8 for {
9 line := os.get_line()
10
11 if line.starts_with('!') {
12 args := line[1..].split(' ')
13
14 if args.len > 0 {
15 match args[0] {
16 'adduser' {
17 if args.len > 4 {
18 app.register_user(args[1], args[2], args[3], args[4..], false, false)!
19 println('Added user ${args[1]}')
20 } else {
21 error('Not enough arguments (3 required but only ${args.len} given)')
22 }
23 }
24 else {
25 println('Commands:')
26 println(' !updaterepo')
27 println(' !adduser <username> <password> <email1> <email2>...')
28 }
29 }
30 } else {
31 error('Unkown syntax. Use !<command>')
32 }
33 } else {
34 error('Unkown syntax. Use !<command>')
35 }
36 }
37}
38