+
Skip to content

Port to Rust #3

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/.stack-work/
/stack.yaml.lock
/*.cabal
/target

/.trace
242 changes: 242 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "tracer"
version = "0.2.0"
description = "Manually instrument a script with spans and traces"
authors = ["Andrew Cowie"]
edition = "2024"
license = "MIT"
repository = "https://github.com/aesiniath/tracer"

[dependencies]
clap = { version = "4.5.32", features = ["wrap_help"] }
2 changes: 0 additions & 2 deletions hie.yaml

This file was deleted.

41 changes: 0 additions & 41 deletions package.yaml

This file was deleted.

87 changes: 87 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
use clap::{Arg, ArgAction, Command};

fn main() {
const VERSION: &str = concat!("v", env!("CARGO_PKG_VERSION"));

let matches = Command::new("tracer")
.version(VERSION)
.propagate_version(true)
.author("Andrew Cowie")
.about("Manually instrument a script with spans and traces.")
.disable_help_subcommand(true)
.disable_help_flag(true)
.disable_version_flag(true)
.arg(
Arg::new("help")
.long("help")
.long_help("Print help")
.global(true)
.hide(true)
.action(ArgAction::Help))
.arg(
Arg::new("version")
.long("version")
.long_help("Print version")
.global(true)
.hide(true)
.action(ArgAction::Version))
.arg(
Arg::new("trace-file")
.long("trace-file")
.action(ArgAction::SetTrue)
.help("File to record the trace and root span identifier in. The default filename is .trace in the current working directory. If you override it when initializing you will need to use the same file for all subsequent invocations making up this procedure."))
.subcommand(
Command::new("init")
.about("Create a trace and root span identifier and mark the start time of your trace.")
.arg(
Arg::new("watch")
.long("watch")
.action(clap::ArgAction::SetTrue)
.help("Watch the given procedure file and recompile if changes are detected."),
)
.arg(
Arg::new("filename")
.required(true)
.help("The file containing the code for the procedure you want to type-check."),
),
)
.subcommand(
Command::new("exec")
.about("Wrap the execution of a command in a span, recording its start time and duration.")
.arg(
Arg::new("label")
.required(true)
.help("Name for the span that will enclose the command you are running. By convention th e label used for the step is the name of the program, script, or function you are executing, rather than a descriptive string."),
)
.arg(
Arg::new("command")
.required(true)
.help("The program to run. It needs to either be an absolute path or a binary by that name must be on your PATH."),
),

)
.subcommand(
Command::new("send")
.about("Send the root span, finishing the corresponding trace.")
.arg(
Arg::new("label")
.required(true)
.help("Name for the root span. By convention this is the identifier or codename for the process being undertaken."),
)
)

.get_matches();

match matches.subcommand() {
Some(("check", _)) => {
todo!();
}
Some(_) => {
println!("An invalid subcommand was used")
}
None => {
println!("usage: tracer [COMMAND] ...");
println!("Try '--help' for more information.");
}
}
}
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载