Skip to main content

P4Cli

Struct P4Cli 

Source
pub struct P4Cli { /* private fields */ }

Implementations§

Source§

impl P4Cli

Source

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.

Source

pub fn bin(self, bin: impl Into<PathBuf>) -> Self

Set the Perforce command path.

Source

pub fn global_opts(self, global_opts: GlobalOpts) -> Self

Set the global options.

Source

pub fn get_bin(&self) -> &Path

Get the Perforce command path.

Source

pub fn get_global_opts(&self) -> &GlobalOpts

Get the global options.

Source

pub fn set_bin(&mut self, bin: impl Into<PathBuf>)

Set the Perforce command path.

Source

pub fn set_global_opts(&mut self, global_opts: GlobalOpts)

Set the global options.

Source

pub fn add(&self) -> Add

Open files in a client workspace for addition to the depot.

Source

pub fn admin(&self) -> AdminEntry

Perform administrative operations on the server.

Source

pub fn aliases(&self) -> Aliases

Display command aliases that are currently defined in a .p4aliases file.

Source

pub fn annotate(&self) -> Annotate

Print file lines along with their revisions.

Source

pub fn archive(&self) -> Archive

Archive obsolete revisions to an archive depot.

Source

pub fn attribute(&self) -> Attribute

Set per-revision attributes on file revisions.

Source

pub fn bgtask(&self) -> BackGroundTask

Run a background command or trigger on the server.

The returned builder starts with no task target; call BackGroundTask::execute (-e) or BackGroundTask::trigger (-t) to select the required target before spawning.

Source

pub fn branch(&self) -> Branch

Create or edit a branch mapping and its view.

Source

pub fn branches(&self) -> Branches

List existing branch mappings.

Source

pub fn cachepurge(&self) -> CachePurge

Reclaim disk space on a replicated server.

The returned builder starts with no purge goal and has no effect; call CachePurge::purge_all (-a), CachePurge::free_space (-f), CachePurge::revision_count (-m), or CachePurge::size (-s) to select the required goal before spawning.

Source

pub fn clean(&self) -> Clean

Restore client workspace files to match the state of corresponding depot files.

Without file arguments, the files in your local working directory are used; pass file arguments to ParameterizedSpawn::spawn_with to limit the scope.

Source

pub fn client(&self) -> Client

Create or edit a client workspace specification and its view.

The returned builder starts in the GeneralMode state (p4 client [-f] [-t template] [-T type] [name]); call transition methods such as Client::delete or Client::stdout to select another syntax form.

Source

pub fn workspace(&self) -> Client

Create or edit a client workspace specification and its view.

This is an alias for Self::client, corresponding to the p4 workspace command.

Source

pub fn change(&self) -> Change

Create or edit a changelist specification.

Source

pub fn changelist(&self) -> Change

Create or edit a changelist specification.

This is an alias for Self::change, corresponding to the p4 changelist command.

Source

pub fn changes(&self) -> Changes

List submitted and pending changelists.

Source

pub fn changelists(&self) -> Changes

List submitted and pending changelists.

This is an alias for Self::changes, corresponding to the p4 changelists command.

Source

pub fn describe(&self) -> Describe

Display the details of one or more changelists.

Source

pub fn diff(&self) -> Diff

Diff workspace content against depot content, or diff stream specs.

Examples found in repository?
examples/diff.rs (line 46)
37fn main() -> std::io::Result<()> {
38    let p4 = P4Cli::default();
39
40    // Workspace mode: force a diff against head, use the unified format with
41    // whitespace-insensitive comparison, and limit output to the first 10
42    // files. `force(true)` transitions the command into `WorkspaceMode`, and
43    // `limit(10)` further transitions it into `WorkspaceRegularMode` (where
44    // `-soptions` is unavailable).
45    let mut diff = p4
46        .diff()
47        .force(true)
48        .diff_options(DiffOptionsBuilder::unified(None).ignore_all_whitespace())
49        .limit(10);
50
51    let files = [OsStr::new("//depot/project/src/...")];
52    let output = diff.output_with((&files,))?;
53    println!("{}", String::from_utf8_lossy(&output.stdout));
54
55    // Display mode: instead of full diffs, list only the unopened files that
56    // differ from the depot. `display_options` transitions `WorkspaceMode`
57    // into `WorkspaceDisplayMode`, where `-m max` is unavailable.
58    let mut list_changed = p4
59        .diff()
60        .force(true)
61        .display_options(DisplayOptions::UnopenedChanged);
62
63    let output = list_changed.output(files)?;
64    println!("{}", String::from_utf8_lossy(&output.stdout));
65
66    // Stream-spec mode: diff a privately edited stream spec against the head
67    // version of another stream. `stream_spec_mode` transitions the command
68    // into `StreamSpecMode`; the stream spec is passed to `spawn_with`.
69    #[cfg(not(feature = "lt2019_1"))]
70    {
71        let mut stream_diff = p4.diff().stream_spec_mode();
72        let mut child = stream_diff.spawn_with(("//streams/main@head",))?;
73        child.wait()?;
74    }
75
76    Ok(())
77}
Source

pub fn diff2(&self) -> Diff2

Compare the content at two depot paths, or compare two stream specs.

Source

pub fn edit(&self) -> Edit

Open files in a client workspace for edit.

Source

pub fn filelog(&self) -> FileLog

Print detailed information about the revisions of files.

Examples found in repository?
examples/filelog.rs (line 31)
24fn main() -> std::io::Result<()> {
25    let p4 = P4Cli::default();
26
27    // Revision history for every file under //depot/project: follow the file
28    // history across branches (`-i`), display the time as well as the date
29    // (`-t`), and list only the first 10 changes per file (`-m 10`).
30    let mut filelog = p4
31        .filelog()
32        .follow_branches(true)
33        .include_time(true)
34        .limit(10);
35
36    let files = [OsStr::new("//depot/project/...")];
37    let output = filelog.output(&files)?;
38    println!("{}", String::from_utf8_lossy(&output.stdout));
39
40    // Long output: `full_description()` transitions the command into the
41    // `FullDescription` state (`-l`), printing the full text of each
42    // changelist description. A revision range limits the listed revisions,
43    // e.g. changelists 100 through 120.
44    let mut long_log = p4.filelog().full_description();
45
46    let output = long_log.output(&["//depot/project/main.c@100,@120"])?;
47    println!("{}", String::from_utf8_lossy(&output.stdout));
48
49    // Content history: `content_history()` transitions the command into the
50    // `DisplayContentHistory` state (`-h`), which unlocks `-p` to skip the
51    // content of promoted task streams. Only revisions submitted at
52    // changelist 4321 are displayed (`-c 4321`).
53    let mut history = p4
54        .filelog()
55        .content_history()
56        .skip_promoted_tasks(true)
57        .changelist("4321");
58
59    let mut child = history.spawn_with((&files,))?;
60    child.wait()?;
61
62    Ok(())
63}
Source

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}
Source

pub fn sync(&self) -> Sync

Update the client workspace to reflect the contents of the depot.

Source

pub fn where(&self) -> Where

Show where a particular file is located, as determined by the client view.

Trait Implementations§

Source§

impl Clone for P4Cli

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for P4Cli

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for P4Cli

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.