Skip to content

Commit

Permalink
Improve format
Browse files Browse the repository at this point in the history
  • Loading branch information
Iam-WenYi committed Aug 25, 2024
1 parent acc7d53 commit 843aed4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Pikiwidb is compiled by default in release mode, which does not support debuggin
## Run

```bash
bin/pikiwidb -c etc/conf/pikiwidb.conf
./bin/pikiwidb ./etc/conf/pikiwidb.conf
```

## Support module for write your own extensions
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PikiwiDB 默认以 release 模式编译,不支持调试。如果需要调试
## 运行

```bash
bin/pikiwidb -c etc/conf/pikiwidb.conf
./bin/pikiwidb ./etc/conf/pikiwidb.conf
```

## 与 Redis 完全兼容
Expand Down
26 changes: 13 additions & 13 deletions src/pikiwidb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void Usage() {
std::cerr << "pikiwidb is the PikiwiDB server.\n";
std::cerr << "\n";
std::cerr << "Usage:\n";
std::cerr << " pikiwidb [options]\n";
std::cerr << " pikiwidb [/path/to/pikiwidb.conf] [options]\n";
std::cerr << "\n";
std::cerr << "Options:\n";
std::cerr << " -v, --version output version information, then exit\n";
Expand All @@ -69,35 +69,35 @@ static void Usage() {
std::cerr << " -l LEVEL, --loglevel LEVEL Set the log level\n";
std::cerr << " -s ADDRESS, --slaveof ADDRESS Set the slave address\n";
std::cerr << "Examples:\n";
std::cerr << " pikiwidb --config /etc/redis/6379.conf\n";
std::cerr << " pikiwidb --config /etc/myredis.conf --loglevel verbose\n";
std::cerr << " pikiwidb /path/pikiwidb.conf\n";
std::cerr << " pikiwidb /path/pikiwidb.conf --loglevel verbose\n";
std::cerr << " pikiwidb --port 7777\n";
std::cerr << " pikiwidb --port 7777 --slaveof 127.0.0.1:8888\n";
}

// Handle the argc & argv
bool PikiwiDB::ParseArgs(int argc, char* argv[]) {
static struct option long_options[] = {
{"config", required_argument, 0, 'c'}, {"version", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'}, {"port", required_argument, 0, 'p'},
{"loglevel", required_argument, 0, 'l'}, {"slaveof", required_argument, 0, 's'},
{"version", no_argument, 0, 'v'}, {"help", no_argument, 0, 'h'},
{"port", required_argument, 0, 'p'}, {"loglevel", required_argument, 0, 'l'},
{"slaveof", required_argument, 0, 's'},
};
// pikiwidb [/path/to/pikiwidb.conf] [options]
if (cfg_file_.empty() && ::access(argv[1], R_OK) == 0) {
cfg_file_ = argv[1];
argc = argc - 1;
argv = argv + 1;
}
while (1) {
int this_option_optind = optind ? optind : 1;
int option_index = 0;
int c;
c = getopt_long(argc, argv, "c:vhp:l:s:", long_options, &option_index);
c = getopt_long(argc, argv, "vhp:l:s:", long_options, &option_index);
if (c == -1) {
break;
}

switch (c) {
case 'c': {
if (cfg_file_.empty() && ::access(optarg, R_OK) == 0) {
cfg_file_ = optarg;
}
break;
}
case 'v': {
std::cerr << "PikiwiDB Server version: " << KPIKIWIDB_VERSION << " bits=" << (sizeof(void*) == 8 ? 64 : 32)
<< std::endl;
Expand Down

0 comments on commit 843aed4

Please sign in to comment.