-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic command prompt #376
Basic command prompt #376
Conversation
WalkthroughThe changes introduce a new crate, Changes
Sequence DiagramsequenceDiagram
participant User
participant CLI
participant Prompter
participant Env
participant PosixExpander
User->>CLI: Start interactive shell
CLI->>Prompter: Apply prompt decorator
Prompter->>Env: Retrieve prompt template ($PS1)
Prompter->>PosixExpander: Expand POSIX prompt
PosixExpander->>Prompter: Return expanded prompt
Prompter->>CLI: Display prompt
User->>CLI: Enter command
CLI->>Prompter: Remove prompt decorator
CLI->>Env: Execute command
Env-->>CLI: Command result
CLI-->>User: Output result
Possibly related issues
Poem
Tip AI model upgrade
|
This commit adds the minimum code to show the default prompt. The prompt is hardcoded to "$ " for now. The prompt is shown before reading the input from the inner input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (9)
- check-extra.sh (3 hunks)
- check-msrv.sh (1 hunks)
- yash-prompt/CHANGELOG.md (1 hunks)
- yash-prompt/Cargo.toml (1 hunks)
- yash-prompt/LICENSE-GPL (1 hunks)
- yash-prompt/README.md (1 hunks)
- yash-prompt/src/expand_posix.rs (1 hunks)
- yash-prompt/src/lib.rs (1 hunks)
- yash-prompt/src/prompter.rs (1 hunks)
Files skipped from review due to trivial changes (3)
- check-extra.sh
- yash-prompt/CHANGELOG.md
- yash-prompt/README.md
Additional comments not posted (19)
yash-prompt/Cargo.toml (3)
1-14
: LGTM!The package metadata is complete and correct.
16-20
: LGTM!The dependencies are correctly specified.
22-24
: LGTM!The dev-dependencies are correctly specified.
yash-prompt/src/lib.rs (3)
1-15
: LGTM!The license header is correctly specified.
21-21
: LGTM!The module imports are correctly specified.
Also applies to: 26-26
22-22
: LGTM!The module exports are correctly specified.
Also applies to: 27-27
check-msrv.sh (3)
Line range hint
1-7
: LGTM!The script setup is correctly specified.
43-45
: LGTM!The workspace member updates are correctly specified.
44-45
: LGTM!The cargo commands are correctly specified.
yash-prompt/src/expand_posix.rs (6)
1-15
: LGTM!The license header is correctly specified.
17-35
: LGTM!The documentation is complete and correctly specified.
19-24
: LGTM!The imports are correctly specified.
36-51
: LGTM!The function implementation is complete and correctly specified.
53-67
: LGTM!The helper function is complete and correctly specified.
69-167
: LGTM!The tests are complete and correctly specified.
yash-prompt/src/prompter.rs (3)
32-35
: Caution: Avoid holdingRefCell
references acrossawait
points.Holding a
RefCell
reference acrossawait
points can lead to runtime panics if theRefCell
is borrowed again before the first borrow is released.Ensure that all
RefCell
borrows are dropped before anyawait
points to avoid potential runtime panics.
37-47
: LGTM!The
new
function correctly initializes thePrompter
struct.
80-177
: LGTM!The test module provides comprehensive test coverage for the
Prompter
struct.yash-prompt/LICENSE-GPL (1)
1-674
: LGTM!The
LICENSE-GPL
file contains the standard text for the GNU General Public License version 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (2)
- yash-cli/Cargo.toml (1 hunks)
- yash-cli/src/startup.rs (4 hunks)
Files skipped from review due to trivial changes (1)
- yash-cli/Cargo.toml
Additional comments not posted (4)
yash-cli/src/startup.rs (4)
28-28
: Import statement approved.The
use yash_env::option::State::On;
import statement is necessary for using theOn
state in the code.
35-35
: Import statement approved.The
use yash_prompt::Prompter;
import statement is necessary for using thePrompter
decorator in the code.
80-85
: Documentation comments approved.The added comments provide valuable information about the
prepare_input
function's behavior and the conditions under which thePrompter
decorator is applied.
Line range hint
96-114
: Conditional application ofPrompter
decorator approved.The changes ensure that the
Prompter
decorator is applied when the shell is interactive and the source is the standard input. This is a correct and necessary modification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- yash-prompt/src/lib.rs (1 hunks)
- yash-prompt/src/prompter.rs (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- yash-prompt/src/lib.rs
- yash-prompt/src/prompter.rs
Additional context used
Learnings (1)
Common learnings
Learnt from: magicant PR: magicant/yash-rs#376 File: yash-prompt/src/lib.rs:17-19 Timestamp: 2024-07-03T03:32:18.685Z Learning: The `yash-prompt` crate provides functionalities to show a command prompt, including the `expand_posix` function and the `Prompter` struct.
This is part of #372. This PR only supports
$PS1
.yash-prompt
cratePrompter
input decoratorPrompter
decoratorSummary by CodeRabbit
New Features
yash-prompt
package for enhanced command prompt functionality.Documentation
README.md
andCHANGELOG.md
foryash-prompt
.yash-prompt
.Refactor
yash-cli
to useyash-prompt
for command prompt implementation.prepare_input
function to conditionally apply thePrompter
decorator.Tests
yash-prompt
functionalities.