pub struct P4Cli { /* private fields */ }Implementations§
Source§impl P4Cli
impl P4Cli
Sourcepub fn new(bin: impl Into<PathBuf>, global_opts: GlobalOpts) -> Self
pub fn new(bin: impl Into<PathBuf>, global_opts: GlobalOpts) -> Self
Create a new Perforce command-line client.
bin is the path to the Perforce command-line executable.
Sourcepub fn global_opts(self, global_opts: GlobalOpts) -> Self
pub fn global_opts(self, global_opts: GlobalOpts) -> Self
Set the global options.
Sourcepub fn get_global_opts(&self) -> &GlobalOpts
pub fn get_global_opts(&self) -> &GlobalOpts
Get the global options.
Sourcepub fn set_global_opts(&mut self, global_opts: GlobalOpts)
pub fn set_global_opts(&mut self, global_opts: GlobalOpts)
Set the global options.
Sourcepub fn admin(&self) -> AdminEntry
pub fn admin(&self) -> AdminEntry
Perform administrative operations on the server.
Sourcepub fn aliases(&self) -> Aliases
pub fn aliases(&self) -> Aliases
Display command aliases that are currently defined in a .p4aliases file.
Sourcepub fn changelists(&self) -> Changes
pub fn changelists(&self) -> Changes
List submitted and pending changelists.
This is an alias for Self::changes, corresponding to the p4 changelists command.
Sourcepub fn diff(&self) -> Diff
pub fn diff(&self) -> Diff
Diff workspace content against depot content, or diff stream specs.
Examples found in repository?
examples/diff.rs (line 36)
27fn main() -> std::io::Result<()> {
28 let p4 = P4Cli::default();
29
30 // Workspace mode: force a diff against head, use the unified format with
31 // whitespace-insensitive comparison, and limit output to the first 10
32 // files. `force(true)` transitions the command into `WorkspaceMode`, and
33 // `limit(10)` further transitions it into `WorkspaceRegularMode` (where
34 // `-soptions` is unavailable).
35 let mut diff = p4
36 .diff()
37 .force(true)
38 .diff_options(DiffOptionsBuilder::unified(None).ignore_all_whitespace())
39 .limit(10);
40
41 let files = [OsStr::new("//depot/project/src/...")];
42 let output = diff.output_with(&files)?;
43 println!("{}", String::from_utf8_lossy(&output.stdout));
44
45 // Display mode: instead of full diffs, list only the unopened files that
46 // differ from the depot. `display_options` transitions `WorkspaceMode`
47 // into `WorkspaceDisplayMode`, where `-m max` is unavailable.
48 let mut list_changed = p4
49 .diff()
50 .force(true)
51 .display_options(DisplayOptions::UnopenedChanged);
52
53 let output = list_changed.output_with(&files)?;
54 println!("{}", String::from_utf8_lossy(&output.stdout));
55
56 // Stream-spec mode: diff a privately edited stream spec against the head
57 // version of another stream. `stream_spec_mode` transitions the command
58 // into `StreamSpecMode`; the stream spec is passed to `spawn_with`.
59 let mut stream_diff = p4.diff().stream_spec_mode();
60 let mut child = stream_diff.spawn_with(Some("//streams/main@head"))?;
61 child.wait()?;
62
63 Ok(())
64}Sourcepub fn diff2(&self) -> Diff2
pub fn diff2(&self) -> Diff2
Compare the content at two depot paths, or compare two stream specs.
Sourcepub fn print(&self) -> Print
pub fn print(&self) -> Print
Print the contents of depot file revisions.
Examples found in repository?
examples/print.rs (line 21)
15fn main() -> std::io::Result<()> {
16 let p4 = P4Cli::default();
17
18 // Chain builders: print all revisions of the first two matching files to
19 // a local output file, without the depot header line.
20 let mut print = p4
21 .print()
22 .all_revisions(true)
23 .quiet_mode(true)
24 .limit(2)
25 .redirect_output("print-output.txt");
26
27 // Run the command to completion and capture its output.
28 let file = Path::new("//depot/project/README.md");
29 let output = print.output_with(&[file.as_os_str()])?;
30 println!("{}", String::from_utf8_lossy(&output.stdout));
31
32 // Or stream the contents directly to the terminal with `spawn_with`.
33 let mut child = p4
34 .print()
35 .spawn_with(&[OsStr::new("//depot/project/README.md")])?;
36 child.wait()?;
37
38 Ok(())
39}Trait Implementations§
Auto Trait Implementations§
impl Freeze for P4Cli
impl RefUnwindSafe for P4Cli
impl Send for P4Cli
impl Sync for P4Cli
impl Unpin for P4Cli
impl UnsafeUnpin for P4Cli
impl UnwindSafe for P4Cli
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more