Expand description
A Rust library for creating and parsing Launchd files.
It’s still in early development and all help is welcome.
Example
use launchd::{CalendarInterval, Error, Launchd};
fn main() -> Result<(), Error> {
let ci = CalendarInterval::default()
.with_hour(12)?
.with_minute(10)?
.with_weekday(7)?;
let launchd = Launchd::new("LABEL", "./foo/bar.txt")?
.with_user_name("Henk")
.with_program_arguments(vec!["Hello".to_string(), "World!".to_string()])
.with_start_calendar_intervals(vec![ci])
.disabled();
#[cfg(feature="io")] // Default
return launchd.to_writer_xml(std::io::stdout());
#[cfg(not(feature="io"))] // If you don't want to build any optional dependencies
return Ok(());
}
Results in:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>LABEL</string>
<key>Disabled</key>
<true />
<key>UserName</key>
<string>Henk</string>
<key>Program</key>
<string>./foo/bar.txt</string>
<key>ProgramArguments</key>
<array>
<string>Hello</string>
<string>World!</string>
</array>
<key>StartCalendarIntervals</key>
<array>
<dict>
<key>Minute</key>
<integer>10</integer>
<key>Hour</key>
<integer>12</integer>
<key>Weekday</key>
<integer>7</integer>
</dict>
</array>
</dict>
</plist>
Re-exports
pub use self::keep_alive::KeepAliveOptions;
pub use self::keep_alive::KeepAliveType;
pub use self::mach_services::MachServiceEntry;
pub use self::mach_services::MachServiceOptions;
pub use self::process_type::ProcessType;
pub use self::resource_limits::ResourceLimits;
pub use self::sockets::BonjourType;
pub use self::sockets::Socket;
pub use self::sockets::SocketOptions;
pub use self::sockets::Sockets;
Modules
Structs
- Representation of a CalendarInterval
- Representation of a launchd.plist file. The definition of which can be found here.