[][src]Function sliderule::create_component

pub fn create_component(
    target_dir: &Path,
    name: String,
    source_license: String,
    doc_license: String
) -> SROutput

Creates a new component or converts an existing directory into a component.

If target_dir is not a component directory, a new, top-level project component will be created. If target_dir is a component directory, a new component is created in the existing components directory. The name of the component is determine by the name parameter. Names are not allowed to include dots. The source materials license source_license and documentation license (doc_license) must be specified and must be from the SPDX license list.

Examples

Creating a new top-level project component:

extern crate sliderule;

let temp_dir = std::env::temp_dir();

let output = sliderule::create_component(
    &temp_dir,
    String::from("newproject"),
    String::from("TestSourceLicense"),
    String::from("TestDocLicense"),
);

assert!(temp_dir.join("newproject").exists());

Creating a new local component:

extern crate sliderule;

let temp_dir = std::env::temp_dir().join("newproject");

let output = sliderule::create_component(
    &temp_dir,
    String::from("localcomponent"),
    String::from("TestSourceLicense"),
    String::from("TestDocLicense"),
);

assert!(temp_dir.join("components").join("localcomponent").exists());