7 releases
new 0.5.10 | Feb 19, 2025 |
---|---|
0.5.9 | Feb 19, 2025 |
#4 in #个人使用的rust工具库
110 downloads per month
Used in wang-utils
10KB
160 lines
个人使用的rust工具库
主要用于简化rust开发
Feature整理
该库拆分成了多个feature,默认情况下会引用部分feature,如需其他非默认的请自行添加
名称 | 是否默认 | 简介 |
---|---|---|
full | 包含全部feature | |
core | √ | 标准库通用工具 |
logger | √ | 日志相关工具 |
command | 命令行相关工具 | |
map | map相关工具 | |
git | git相关工具 | |
json | √ | json相关工具 |
lib.rs
:
git操作相关工具
示例
use git2::Repository;
use std::fs;
use wang_utils_git::{git_add, git_commit, git_read_commits, git_read_tag, git_status, git_tag};
fn main() -> anyhow::Result<()> {
let test_folder = "~/test_git_folder";
let repo = Repository::open(&test_folder)?;
// 输出文件
fs::write("~/test_git_folder/test.txt", "111")?;
git_add(&repo)?; //git add .
println!("status:{:?}", git_status(&repo)?);
git_commit(&repo, "initial commit")?; //git commit -m "xxx"
println!("status:{:?}", git_status(&repo)?);
println!("commits:{:?}", git_read_commits(&repo)?);
println!("tags:{:?}", git_read_tag(&repo)?);
git_tag(&repo, "v1.2.14")?;
println!("tags:{:?}", git_read_tag(&repo)?);
Ok(())
}
Dependencies
~11MB
~253K SLoC