Skip to content

Commit

Permalink
Merge pull request #176 from azriel91/feature/157/id-newtype-macro-us…
Browse files Browse the repository at this point in the history
…e-qualified-path
  • Loading branch information
azriel91 authored Jan 10, 2024
2 parents 28bbde4 + 391f227 commit 47e4871
Show file tree
Hide file tree
Showing 62 changed files with 82 additions and 73 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
## unreleased

* Provide more accurate feedback about interruption on CLI. ([#172], [#173])
* Remove requirement to import `peace::cfg::AppName` when using `app_name!("..")` macro. ([#157], [#176])
* Remove requirement to import `peace::cfg::FlowId` when using `flow_id!("..")` macro. ([#157], [#176])
* Remove requirement to import `peace::cfg::ItemId` when using `item_id!("..")` macro. ([#157], [#176])
* Remove requirement to import `peace::cfg::Profile` when using `profile!("..")` macro. ([#157], [#176])


[#172]: https://github.com/azriel91/peace/issues/172
[#173]: https://github.com/azriel91/peace/pull/173
[#157]: https://github.com/azriel91/peace/issues/157
[#176]: https://github.com/azriel91/peace/pull/176


## 0.0.12 (2023-12-30)
Expand Down
17 changes: 13 additions & 4 deletions crate/static_check_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ fn ensure_valid_id(
if let Some(proposed_id) = proposed_id {
if is_valid_id(proposed_id) {
let ty_name = Ident::new(ty_name, Span::call_site());
quote!( #ty_name ::new_unchecked( #proposed_id ))
quote!( peace::cfg:: #ty_name ::new_unchecked( #proposed_id ))
} else {
let message = format!(
"\"{proposed_id}\" is not a valid `{ty_name}`.\n\
Expand Down Expand Up @@ -232,7 +232,10 @@ mod tests {
None,
);

assert_eq!(r#"Ty :: new_unchecked ("_")"#, tokens.to_string());
assert_eq!(
r#"peace :: cfg :: Ty :: new_unchecked ("_")"#,
tokens.to_string()
);
}

#[test]
Expand All @@ -242,15 +245,21 @@ mod tests {
"Ty",
None,
);
assert_eq!(r#"Ty :: new_unchecked ("a")"#, tokens.to_string());
assert_eq!(
r#"peace :: cfg :: Ty :: new_unchecked ("a")"#,
tokens.to_string()
);

let tokens = ensure_valid_id(
&LitStrMaybe(Some(LitStr::new("A", Span::call_site()))),
"Ty",
None,
);

assert_eq!(r#"Ty :: new_unchecked ("A")"#, tokens.to_string());
assert_eq!(
r#"peace :: cfg :: Ty :: new_unchecked ("A")"#,
tokens.to_string()
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion examples/download/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, item_id, AppName, FlowId, ItemId, Profile},
cfg::{app_name, item_id, FlowId, ItemId, Profile},
cmd::{ctx::CmdCtx, scopes::SingleProfileSingleFlow},
cmd_model::CmdOutcome,
resources::resources::ts::SetUp,
Expand Down
2 changes: 1 addition & 1 deletion examples/download/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::Parser;
use peace::{
cfg::{flow_id, profile, FlowId, Profile},
cfg::{flow_id, profile},
rt_model::{output::CliOutput, WorkspaceSpec},
};
use peace_items::file_download::FileDownloadParams;
Expand Down
2 changes: 1 addition & 1 deletion examples/download/src/wasm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{flow_id, profile, FlowId, Profile},
cfg::{flow_id, profile},
rt_model::{InMemoryTextOutput, WorkspaceSpec},
};
use peace_items::file_download::{FileDownloadParams, StorageForm};
Expand Down
2 changes: 1 addition & 1 deletion examples/envman/src/cmds/app_upload_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use futures::future::LocalBoxFuture;
use peace::{
cfg::{app_name, item_id, AppName, ItemId, Profile},
cfg::{app_name, item_id, Profile},
cmd::{
ctx::CmdCtx,
scopes::{
Expand Down
2 changes: 1 addition & 1 deletion examples/envman/src/cmds/common.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, AppName},
cfg::app_name,
cmd::ctx::CmdCtx,
rt_model::{output::OutputWrite, Workspace, WorkspaceSpec},
};
Expand Down
2 changes: 1 addition & 1 deletion examples/envman/src/cmds/env_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use futures::future::LocalBoxFuture;
use peace::{
cfg::{app_name, item_id, state::Generated, AppName, ItemId, Profile},
cfg::{app_name, item_id, state::Generated, Profile},
cmd::{
ctx::CmdCtx,
scopes::{
Expand Down
2 changes: 1 addition & 1 deletion examples/envman/src/cmds/profile_init_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, item_id, AppName, ItemId, Profile},
cfg::{app_name, item_id, Profile},
cmd::{
ctx::CmdCtx,
scopes::{
Expand Down
2 changes: 1 addition & 1 deletion examples/envman/src/cmds/profile_list_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, AppName},
cfg::app_name,
cmd::{ctx::CmdCtx, scopes::MultiProfileNoFlowView},
fmt::presentable::{Heading, HeadingLevel},
rt_model::{output::OutputWrite, Workspace, WorkspaceSpec},
Expand Down
2 changes: 1 addition & 1 deletion examples/envman/src/cmds/profile_show_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, AppName, Profile},
cfg::{app_name, Profile},
cmd::{ctx::CmdCtx, scopes::SingleProfileNoFlowView},
fmt::presentln,
rt_model::{output::OutputWrite, Workspace, WorkspaceSpec},
Expand Down
2 changes: 1 addition & 1 deletion examples/envman/src/cmds/profile_switch_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, AppName},
cfg::app_name,
cmd::{ctx::CmdCtx, scopes::MultiProfileNoFlowView},
rt_model::output::OutputWrite,
};
Expand Down
2 changes: 1 addition & 1 deletion examples/envman/src/flows/app_upload_flow.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::PathBuf;

use peace::{
cfg::{app_name, flow_id, item_id, AppName, FlowId, ItemId, Profile},
cfg::{app_name, flow_id, item_id, Profile},
params::{Params, ParamsSpec},
rt_model::{Flow, ItemGraphBuilder},
};
Expand Down
2 changes: 1 addition & 1 deletion examples/envman/src/flows/env_deploy_flow.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::PathBuf;

use peace::{
cfg::{app_name, flow_id, item_id, state::Generated, AppName, FlowId, ItemId, Profile},
cfg::{app_name, flow_id, item_id, state::Generated, Profile},
params::{Params, ParamsSpec},
rt_model::{Flow, ItemGraphBuilder},
};
Expand Down
1 change: 0 additions & 1 deletion workspace_tests/src/cfg/progress/progress_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use peace::{
CmdProgressUpdate, ProgressDelta, ProgressMsgUpdate, ProgressSender,
ProgressUpdateAndId,
},
ItemId,
},
rt_model::ProgressUpdate,
};
Expand Down
1 change: 0 additions & 1 deletion workspace_tests/src/cfg/progress/progress_update_and_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use peace::cfg::{
ProgressComplete, ProgressDelta, ProgressLimit, ProgressMsgUpdate, ProgressUpdate,
ProgressUpdateAndId,
},
ItemId,
};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/cmd/ctx/cmd_ctx.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, flow_id, profile, AppName, FlowId, Profile},
cfg::{app_name, flow_id, profile, AppName},
cmd::ctx::CmdCtxBuilder,
rt_model::{Flow, ItemGraphBuilder, Workspace},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;

use peace::{
cfg::{app_name, profile, AppName, Profile, ProfileInvalidFmt},
cfg::{app_name, profile, Profile, ProfileInvalidFmt},
cmd::ctx::CmdCtx,
resources::paths::{ProfileDir, ProfileHistoryDir},
rt_model::{params::ParamsTypeRegs, Error as PeaceRtError, NativeError},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;

use peace::{
cfg::{app_name, flow_id, profile, AppName, FlowId, Profile},
cfg::{app_name, flow_id, profile},
cmd::ctx::CmdCtx,
resources::paths::{FlowDir, ProfileDir, ProfileHistoryDir},
rt_model::{params::ParamsTypeRegs, Flow, ItemGraphBuilder, ParamsSpecsTypeReg, StatesTypeReg},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, profile, AppName, Profile},
cfg::{app_name, profile},
cmd::ctx::CmdCtx,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, profile, AppName, Profile},
cfg::{app_name, profile},
cmd::ctx::CmdCtx,
resources::paths::{ProfileDir, ProfileHistoryDir},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, flow_id, item_id, profile, AppName, FlowId, Item, ItemId, Profile},
cfg::{app_name, flow_id, item_id, profile, Item, Profile},
cmd::ctx::CmdCtx,
params::{Params, ParamsSpec, ValueResolutionCtx, ValueResolutionMode, ValueSpec},
resources::{
Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/cmd_model/cmd_block_outcome.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{item_id, ItemId},
cfg::item_id,
cmd_model::{CmdBlockOutcome, StreamOutcomeAndErrors, ValueAndStreamOutcome},
rt_model::{fn_graph::StreamOutcome, IndexMap},
};
Expand Down
6 changes: 1 addition & 5 deletions workspace_tests/src/cmd_model/item_stream_outcome.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use peace::{
cfg::{item_id, ItemId},
cmd_model::ItemStreamOutcome,
rt_model::fn_graph::StreamOutcomeState,
};
use peace::{cfg::item_id, cmd_model::ItemStreamOutcome, rt_model::fn_graph::StreamOutcomeState};

#[test]
fn map() {
Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/cmd_rt/cmd_execution.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, profile, AppName, FlowId, Profile},
cfg::{app_name, profile, FlowId},
cmd::ctx::CmdCtx,
cmd_model::CmdOutcome,
cmd_rt::{CmdBlockRt, CmdBlockWrapper, CmdExecution},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, profile, AppName, FlowId, Profile},
cfg::{app_name, profile, FlowId},
cmd::ctx::CmdCtx,
cmd_model::CmdExecutionError,
cmd_rt::{CmdBlockWrapper, CmdExecution},
Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/items/sh_cmd_item.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{app_name, item_id, profile, AppName, FlowId, ItemId, Profile, State},
cfg::{app_name, item_id, profile, FlowId, ItemId, State},
cmd::ctx::CmdCtx,
cmd_model::CmdOutcome,
data::marker::Clean,
Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/items/tar_x_item.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{io::Cursor, path::PathBuf};

use peace::{
cfg::{app_name, item_id, profile, AppName, ApplyCheck, FlowId, Item, ItemId, Profile},
cfg::{app_name, item_id, profile, ApplyCheck, FlowId, Item, ItemId, Profile},
cmd::{ctx::CmdCtx, scopes::SingleProfileSingleFlowView},
cmd_model::CmdOutcome,
data::Data,
Expand Down
12 changes: 6 additions & 6 deletions workspace_tests/src/params/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ mod struct_params {
use serde::{Deserialize, Serialize};

use peace::{
cfg::{item_id, ItemId},
cfg::item_id,
params::{Params, ParamsSpec, ValueResolutionCtx, ValueResolutionMode, ValueSpec},
resources::{resources::ts::SetUp, Resources},
};
Expand Down Expand Up @@ -269,7 +269,7 @@ mod struct_with_type_params {
use serde::{Deserialize, Serialize};

use peace::{
cfg::{item_id, ItemId},
cfg::item_id,
params::{Params, ParamsSpec, ValueResolutionCtx, ValueResolutionMode, ValueSpec},
resources::{resources::ts::SetUp, Resources},
};
Expand Down Expand Up @@ -489,7 +489,7 @@ mod tuple_params {
use serde::{Deserialize, Serialize};

use peace::{
cfg::{item_id, ItemId},
cfg::item_id,
params::{Params, ParamsSpec, ValueResolutionCtx, ValueResolutionMode, ValueSpec},
resources::{resources::ts::SetUp, Resources},
};
Expand Down Expand Up @@ -665,7 +665,7 @@ mod tuple_with_type_params {
use serde::{Deserialize, Serialize};

use peace::{
cfg::{item_id, ItemId},
cfg::item_id,
params::{Params, ParamsSpec, ValueResolutionCtx, ValueResolutionMode, ValueSpec},
resources::{resources::ts::SetUp, Resources},
};
Expand Down Expand Up @@ -866,7 +866,7 @@ mod enum_params {
use serde::{Deserialize, Serialize};

use peace::{
cfg::{item_id, ItemId},
cfg::item_id,
params::{Params, ParamsSpec, ValueResolutionCtx, ValueResolutionMode, ValueSpec},
resources::{resources::ts::SetUp, Resources},
};
Expand Down Expand Up @@ -1499,7 +1499,7 @@ mod struct_recursive_value {
use serde::{Deserialize, Serialize};

use peace::{
cfg::{item_id, ItemId},
cfg::item_id,
params::{Params, ParamsSpec, ValueResolutionCtx, ValueResolutionMode, ValueSpec},
resources::{resources::ts::SetUp, Resources},
};
Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/params/mapping_fn_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ macro_rules! mapping_tests {
mod $module_name {
use peace::{
data::marker::$value_resolution_mode,
cfg::{item_id, ItemId},
cfg::{item_id},
params::{
MappingFn, MappingFnImpl, ParamsResolveError,
ValueResolutionCtx, ValueResolutionMode,
Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/params/params_spec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{item_id, ItemId},
cfg::item_id,
params::{
AnySpecRt, AnySpecRtBoxed, FieldNameAndType, FieldWiseSpecRt, Params, ParamsResolveError,
ParamsSpec, ValueResolutionCtx, ValueResolutionMode, ValueSpec, ValueSpecRt,
Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/params/params_spec_fieldless.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{item_id, ItemId},
cfg::item_id,
params::{
AnySpecRt, AnySpecRtBoxed, ParamsFieldless, ParamsResolveError, ParamsSpecFieldless,
ValueResolutionCtx, ValueResolutionMode, ValueSpecRt,
Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/params/params_specs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{item_id, ItemId},
cfg::item_id,
params::{ParamsSpec, ParamsSpecs},
};

Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/params/value_resolution_ctx.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{item_id, ItemId},
cfg::item_id,
params::{FieldNameAndType, ValueResolutionCtx, ValueResolutionMode},
};

Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/params/value_spec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use peace::{
cfg::{item_id, ItemId},
cfg::item_id,
params::{
AnySpecRt, AnySpecRtBoxed, ParamsResolveError, ValueResolutionCtx, ValueResolutionMode,
ValueSpec, ValueSpecRt,
Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/resources/dir/profile_dir.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{ffi::OsStr, path::Path};

use peace::{
cfg::{app_name, profile, AppName, Profile},
cfg::{app_name, profile},
resources::paths::{PeaceAppDir, PeaceDir, ProfileDir},
};

Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/resources/dir/profile_history_dir.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{ffi::OsStr, path::Path};

use peace::{
cfg::{app_name, profile, AppName, Profile},
cfg::{app_name, profile},
resources::paths::{PeaceAppDir, PeaceDir, ProfileDir, ProfileHistoryDir},
};

Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/resources/dir/states_current_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use peace::{
cfg::{app_name, flow_id, profile, AppName, FlowId, Profile},
cfg::{app_name, flow_id, profile},
resources::paths::{FlowDir, PeaceAppDir, PeaceDir, ProfileDir, StatesCurrentFile},
};

Expand Down
2 changes: 1 addition & 1 deletion workspace_tests/src/resources/dir/states_goal_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use peace::{
cfg::{app_name, flow_id, profile, AppName, FlowId, Profile},
cfg::{app_name, flow_id, profile},
resources::paths::{FlowDir, PeaceAppDir, PeaceDir, ProfileDir, StatesGoalFile},
};

Expand Down
Loading

0 comments on commit 47e4871

Please sign in to comment.