Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make command args same as C version, fix log timestamp and set socket… #116

Merged
merged 1 commit into from
Apr 13, 2023

Conversation

pymumu
Copy link
Contributor

@pymumu pymumu commented Apr 12, 2023

  1. 修改命令行参数,默认为run,保持和c版本一致。
  2. 修改log打印,输出正确的时间戳。
  3. socket增加reuse选项。

@mokeyish
Copy link
Owner

mokeyish commented Apr 12, 2023

谢谢 PR。关于启动参数,我这边倾向于默认使用 run 子命令的(添加关于 c 版参数的兼容解析),因为很多类似的服务都是这样的,run 代表前台运行。

下面的这个 Caveats 是 homebrew 自动生成的。

图片

兼容的处理方式是,添加把 Run 部分,单独成一个结构体,总的 Cli parse 失败了,再去 parse run 的那个结构体,再调 into() 重新变回 Cli。

你觉得呢?

@pymumu
Copy link
Contributor Author

pymumu commented Apr 12, 2023

Linux下命令行都是-开头,原因是getopt接口
另外默认情况如果不带任何参数,就是使用默认值运行。输入run,其实是多余。如果确实需要前台运行,可以增加forgroud参数。

比如sshd,dnsmasq等,都是这样。这些也是可以用systemd来设置成service服务。

对于Caveats是否可以修改去掉run。

@mokeyish
Copy link
Owner

Linux下命令行都是-开头,原因是getopt接口

这是只是 c 语言才这样吧?缩写是 -,全名是 --,这个基本都这样。

先前是考虑过完全采用 c 的启动命令的,但是考虑到还要继续加子命令,例如提供跨平台的 flush 系统的 dns、以及 service 管理,如果全堆在默认那,看命令行 help 就不容易理解了,以子命令的方式划分就更简单易懂了。所以计划是采用兼容的方式,不过就个人而言不是很紧急的事,没有急着兼容。

@mokeyish
Copy link
Owner

你看现在的 help 先看有哪些子命令,再看子命令的具体用法。

图片

@pymumu
Copy link
Contributor Author

pymumu commented Apr 12, 2023

这里一点是,默认不带任何参数,应该是要能启动提供服务的。
这样也就省去了用户看帮助的麻烦,直接执行命令,或双击命令就能提供服务。

如果加了run参数,用户就必须先看帮助,才知道怎么启动服务。

@mokeyish
Copy link
Owner

这里一点是,默认不带任何参数,应该是要能启动提供服务的。 这样也就省去了用户看帮助的麻烦,直接执行命令,或双击命令就能提供服务。

如果加了run参数,用户就必须先看帮助,才知道怎么启动服务。

run 参数 兼容解析就好了,你能把修改 run 的那部分改成兼容解析或者撤回吗?

Rust 版是没有直接 daemon 后台运行的,我看有些麻烦(类库: daemonize),就没打算搞了,其实 systemd、openwrt 的procd、macos 的 launch 都是可以直接 foregroud 运行的。等 UI 出来,其实后台服务都没必要了,直接套个 tauri,首次使用也是 UI 指引,window 桌面右下角,菜单就能直接调整。

src/main.rs Show resolved Hide resolved
@mokeyish mokeyish merged commit ad8874a into mokeyish:main Apr 13, 2023
@zxlhhyccc
Copy link
Contributor

zxlhhyccc commented Apr 13, 2023

@mokeyish 这个pr是否兼容了c版?我也倾向于@pymumu 大佬的意见!

@mokeyish
Copy link
Owner

提交了兼容 C 版参数的 PR #117

@zxlhhyccc
Copy link
Contributor

提交了兼容 C 版参数的 PR #117

image

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants