Skip to content

Commit

Permalink
test run
Browse files Browse the repository at this point in the history
  • Loading branch information
oligamiq committed Dec 18, 2023
1 parent 38bb29b commit 04da627
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion rust/macos/objc/nick_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl NickName {
cmd.arg("--get").arg("ComputerName");
let out = cmd.output().unwrap().stdout;
let out = String::from_utf8(out).unwrap();
// out: Mac-1702909720453.local
println!("out: {}", out);

msg_send![class!(NSObject), alloc]
Expand All @@ -63,6 +64,7 @@ impl NickName {

let name = self.get_name()?;
println!("name: {}", name);
// name: Mac-1702909720453.local

Ok(hostname)
}
Expand Down Expand Up @@ -137,7 +139,17 @@ impl NickName {

pub fn set<S: Into<String>>(&self, nickname: S) -> crate::Result<()> {
let nickname: String = nickname.into();
self.set_hostname(nickname)?;
self.set_hostname(&nickname)?;

let name = self.get()?;
println!("set name: {}", name);

let mut cmd = std::process::Command::new("scutil");
cmd.arg("--set").arg("ComputerName").arg(nickname);
let out = cmd.output().unwrap().stdout;
let out = String::from_utf8(out).unwrap();
// out: Mac-1702909720453.local
println!("scutil set out: {}", out);

let name = self.get()?;
println!("set name: {}", name);
Expand Down

0 comments on commit 04da627

Please sign in to comment.