-
Notifications
You must be signed in to change notification settings - Fork 94
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
feat(std): more commands #185
Conversation
|
@b1ek all the non-failable GNU commands that are parto of POSIX should be built-in. |
Actually... perhaps built-ins could be failable as well:
|
Let's do a list of commands that need a native support and what needs a function. |
This function should have the following changes
To
|
So I have to removed the non-failable commands from this PR. About |
Probably is missing a function to extract compressed files, download files and to search inside file content. |
I did some changes and added the |
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.
every stdlib command should be covered by a test. the tests are in src/tests/stdlib.rs
added is_root and is_command
I never developed with Rust but I guess that is enough to generate the bash and check that is always the same right? I added also |
@Mte90 if you want to write a standard function to download file, then maybe write one that detects available solution to download it like if {
not has_failed("curl") {
// ... run curl command
}
not has_failed("wget") {
// ... run wget command
}
not has_failed("python") {
// ... run python command (and detect python version)
} |
I think that is better a command that check if exist instead to run it to see what is the error. |
Sure! I just wanted to share an example of potential implementation |
So I think that another round of review for the function so I can try to do the unit tests :-) |
ftfy <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.
lgtm
So I added 3 new commands:
I am fighting with the compilation as we need |
So the |
I don't understand the error reported for the Someone that can help my with the Amber code review? @Ph0enixKM |
This means that the expression you used is failable and you should handle the error @Mte90 |
In the meantime I fixed it, also now the CI should have a green check :-) |
This pr is ready :-) |
fn http_server() { | ||
use tiny_http::{Server, Response}; | ||
|
||
let server = Server::http("127.0.0.1:8081").expect("Can't bind to 127.0.0.1:8081"); | ||
for req in server.incoming_requests() { | ||
req.respond(Response::from_string("ok")).expect("Can't respond"); | ||
break; | ||
} |
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.
Whoa! Didn't expect http_server
in the compiler. Does the curl
actually download a file?
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.
it is used only for tests and that part was implemented by @b1ek.
Because initially I did to download a website but the issue was that what is if the user is not connected to internet or the page is not available?
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.
Looks good to me
* feat(std): more command * removed functions * download * Update main.ab added is_root and is_command * feat(download): improved fallback * amber fix * feat(test): is_command * feat(test): create_symbolic_link * feat(test): added 3 tests * feat(test): added 2 tests * fix(test): download * feat: spin up a small web server for download() test * fix: regenerate Cergo.lock * feat(env): 3 new functions * fix(amber): now should compile * fix(amber): now should compile * fix(amber): clean * fix(test): removed write * fix(test): maybe * fix(test): wip * fix(test): wip * ci(cache): now will use CI cache, so it will be more fast between jobs --------- Co-authored-by: b1ek <me@blek.codes>
So I added more commands:
move
a wrapper aroundmv
change_dir
a wrapper aroundcd
but in this way it is generated acd
command fine for shellcheck [Feature] Integration with shellcheck #72make_symbolic_link
a wrapper aroundln -s
create_dir
a wrapper aroundmkdir -p
make_executable
a wrapper aroundchmod +x
switch_user_permission
a wrapper aroundchown -R
delete
a wrapper aroundrm -fr
In many of those cases there is a check if the file/folder exist, in case return a different boolean value and print the error.
In 2 cases we need the
OR
condition so we can check if it is file and a folder.