MCPcopy Create free account
hub / github.com/SeaQL/FireDBG.for.Rust / list_target

Function list_target

command/src/main.rs:882–1058  ·  view source on GitHub ↗
(
    workspace: &Workspace,
    json_format: bool,
    targets: Vec<ListTarget>,
)

Source from the content-addressed store, hash-verified

880}
881
882async fn list_target(
883 workspace: &Workspace,
884 json_format: bool,
885 targets: Vec<ListTarget>,
886) -> Result<()> {
887 #[derive(Debug, Serialize)]
888 struct Target<'a> {
889 binaries: Vec<&'a Binary>,
890 examples: Vec<&'a Example>,
891 integration_tests: Vec<IntegrationTest<'a>>,
892 unit_tests: Vec<UnitTest<'a>>,
893 }
894
895 #[derive(Debug, Serialize)]
896 struct IntegrationTest<'a> {
897 package_name: &'a str,
898 test: &'a Test,
899 test_cases: Vec<String>,
900 }
901
902 #[derive(Debug, Serialize)]
903 struct UnitTest<'a> {
904 package_name: &'a str,
905 test_cases: Vec<String>,
906 }
907
908 let list_all = targets.contains(&ListTarget::Bin)
909 && targets.contains(&ListTarget::Example)
910 && targets.contains(&ListTarget::Test)
911 && targets.contains(&ListTarget::UnitTest);
912 let list_partial = !list_all
913 && targets.iter().any(|t| {
914 matches!(
915 t,
916 ListTarget::Bin | ListTarget::Example | ListTarget::Test | ListTarget::UnitTest
917 )
918 });
919
920 let binaries: Vec<_> = if list_all || (list_partial && targets.contains(&ListTarget::Bin)) {
921 workspace
922 .packages
923 .iter()
924 .flat_map(|package| &package.binaries)
925 .collect()
926 } else {
927 Vec::new()
928 };
929
930 let examples: Vec<_> = if list_all || (list_partial && targets.contains(&ListTarget::Example)) {
931 workspace
932 .packages
933 .iter()
934 .flat_map(|package| &package.examples)
935 .collect()
936 } else {
937 Vec::new()
938 };
939

Callers 1

mainFunction · 0.85

Calls 4

to_json_fileFunction · 0.85
containsMethod · 0.80
get_firedbg_dirMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected