Skip to content

Commit f0fc798

Browse files
authored
[Feat] add file_path option for detect programming language (#99)
1 parent e81742d commit f0fc798

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cli/src/code.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ pub fn create_code(cli: &CLI, code_config: Code) -> anyhow::Result<Content> {
2727
.start_line_number(parsed_range.0 as u32)
2828
.build()?;
2929

30-
code.file_path = cli.from_file.clone().or(code_config.file_path);
30+
code.file_path = cli
31+
.from_file
32+
.clone()
33+
.or(cli.file_path.clone())
34+
.or(code_config.file_path);
3135
code.language = cli.language.clone().or(code_config.language);
3236
code.highlight_lines = create_highlight_lines(&cli, parsed_range, &code_snippet)?;
3337

cli/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ struct CLI {
164164
#[arg(long, short)]
165165
language: Option<String>,
166166

167+
/// Used to detect the language of the code snippet, if you want to set language manually,
168+
/// use `--language` or `-l` option.
169+
#[arg(long)]
170+
file_path: Option<String>,
171+
167172
/// Set watermark for the code snippet
168173
#[arg(long, short)]
169174
watermark: Option<String>,

0 commit comments

Comments
 (0)