Skip to content

Commit c3401f0

Browse files
fix get version
1 parent b967266 commit c3401f0

File tree

8 files changed

+47
-17
lines changed

8 files changed

+47
-17
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

command/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "command"
3-
version = "1.0.2"
3+
version = "1.0.3"
44
edition = "2021"
55
authors = ["Zhangzijie <[email protected]>"]
66
repository = "https://github.com/zhangzijie-pro/Tiks.git"

command/src/commands/download.rs renamed to command/src/commands/apt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ async fn download(link: &str, filename: &str) -> Result<(),Box<dyn std::error::E
6464

6565
// apt update new
6666

67-
const _GITHUB_RELEASE_LINUX: &str = "https://github.com/zhangzijie-pro/Tiks/releases/download/1.0.1/tiks";
68-
const _GITHUB_RELEASE_WINDOW: &str = "https://github.com/zhangzijie-pro/Tiks/releases/download/1.0.1/tiks.exe";
67+
const _GITHUB_RELEASE_LINUX: &str = "https://github.com/zhangzijie-pro/Tiks/releases/download/1.0.3/tiks";
68+
const _GITHUB_RELEASE_WINDOW: &str = "https://github.com/zhangzijie-pro/Tiks/releases/download/1.0.3/tiks.exe";
6969

7070
// upload soon
7171
#[allow(unused_must_use)]

command/src/commands/arg.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::set::set::get_similar;
22
use crate::root::{decryption, SessionContext};
3+
use crate::set::version;
34
use crate::state_code::{missing_pattern, not_found};
45

56
use super::code::*;
@@ -83,7 +84,17 @@ pub fn command_match(commands: Commands,session_context: &mut SessionContext) ->
8384
#[allow(unused_assignments)]
8485
pub fn execute_command(command: &str, option: &str, arg: &Vec<String>, session_context: &mut SessionContext) -> Result<(usize,String), std::io::Error> {
8586
match command {
86-
"version" => Ok((0,"Tiks-version: 1.0.2".to_string())),
87+
"version" => match option{
88+
"-n"|"now" => {
89+
version::get_version_now()
90+
},
91+
"-l"|"-list" => {
92+
version::get_version_list()
93+
},
94+
_ =>{
95+
Ok((0,"help:\n -n|now: Get version now\n -l|list: Get all version".to_string()))
96+
}
97+
},
8798
"sudo" => match arg.is_empty(){
8899
true => {
89100
let output = sudo(session_context);

command/src/commands/command.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,12 @@ pub fn cat(file: &str) -> Result<(usize,String),Error>{
310310
}
311311

312312

313-
use crate::commands::download::{download_package, find_package};
313+
use crate::commands::apt::{download_package, find_package};
314314
use crate::priority::get_priority;
315315
use crate::set::set::file_create_time;
316316
use crate::run::run;
317317
use crate::state_code::{empty_dir, empty_file, env, missing_pattern, STATUE_CODE};
318-
use super::download::{update, update_last};
318+
use super::apt::{update, update_last};
319319
use crate::root::SessionContext;
320320

321321

@@ -600,9 +600,9 @@ pub fn echo_print<T: std::fmt::Display + From<String>>(output: T) -> (usize,T){
600600
let var = format!("{}", output);
601601
if var.contains("$") {
602602
let val = get_env(var);
603-
return (0, val.into());
603+
return (STATUE_CODE, val.into());
604604
}else{
605-
(0, output)
605+
(STATUE_CODE, output)
606606
}
607607
}
608608

@@ -623,9 +623,4 @@ pub fn test_c(){
623623
unsafe{
624624
hello()
625625
}
626-
}
627-
/*
628-
fn vim(){
629-
630-
}
631-
*/
626+
}

command/src/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pub mod arg;
22
mod code;
3-
pub mod download;
3+
pub mod apt;
44
pub mod command;

command/src/set/mod.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
pub mod set;
1+
pub mod set;
2+
3+
4+
pub mod version{
5+
use std::io::{self, Read};
6+
7+
use crate::state_code::STATUE_CODE;
8+
9+
pub fn get_version_list() -> io::Result<(usize,String)>{
10+
let mut s = String::new();
11+
let mut res = std::fs::File::open("command/test/version").unwrap();
12+
let _ = res.read_to_string(&mut s);
13+
14+
Ok((STATUE_CODE,s))
15+
}
16+
17+
pub fn get_version_now() -> io::Result<(usize,String)>{
18+
let s = env!("CARGO_PKG_VERSION").parse::<String>().unwrap();
19+
Ok((STATUE_CODE,s))
20+
}
21+
}

command/test/version

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1.0.0
2+
1.0.1
3+
1.0.2
4+
1.0.3

0 commit comments

Comments
 (0)