Comments (6)
Surely, a full featured io
/fs
library is a must. Your PR would be more than welcome! Please let me know if I can be of any help.
from hush.
For a 100% feature complete set, I'd consider Rust's own std::fs module:
canonicalize
: Returns the canonical, absolute form of a path with all intermediate components normalized and symbolic links resolved.copy
: Copies the contents of one file to another. This function will also copy the permission bits of the original file to the destination file.create_dir
: Creates a new, empty directory at the provided pathcreate_dir_all
: Recursively create a directory and all of its parent components if they are missing.hard_link
: Creates a new hard link on the filesystem.metadata
: Given a path, query the file system to get information about a file, directory, etc.read
: Read the entire contents of a file into a bytes vector.read_dir
: Returns an iterator over the entries within a directory.read_link
: Reads a symbolic link, returning the file that the link points to.read_to_string
: Read the entire contents of a file into a string.remove_dir
: Removes an empty directory.remove_dir_all
: Removes a directory at this path, after removing all its contents. Use carefully!remove_file
: Removes a file from the filesystem.rename
: Rename a file or directory to a new name, replacing the original file if to already exists.set_permissions
: Changes the permissions found on a file or a directory.soft_linkDeprecated
: Creates a new symbolic link on the filesystem.symlink_metadata
: Query the metadata about a file without following symlinks.write
: Write a slice as the entire contents of a file
from hush.
I was mainly focused on the features I'm missing from bash. I have implementations for std.io.file_exists(...)
and std.io.dir_exists(...)
but I'd be up for adding some additional functions.
Do you have some suggestions for what those could be?
For most other fs operations I'd probably just rely on existing commands and the flexibility they already offer through various arguments. They're not too weird to use either:
# read a file
let mydata = ${ cat "/myfile" }.stdout
# delete a file
{ rm "/myfile" }
# write a file
{ echo "$mydata" > "/myfile" }
On the other hand this marks my first bit of Rust - I'd be up for a challenge.
from hush.
Makes sense, I believe I would use the existing commands in most cases too. It would be nice to have the basic functionality in the standard library tho, just in case. Feel free to implement whichever methods you'd like. And by the way, congrats for your first bit of Rust
from hush.
Fair point - some essential functions would be nice to have. I've listed the ones I could think of. Is there anything I've missed?
from hush.
Some of these would be collapsed into a single function, such as create_dir
and create_dir_all
, also read
and read_to_string
.
from hush.
Related Issues (20)
- Shell capture hangs indefinitely HOT 6
- Access to foreign function interface (FFI)? HOT 4
- Will REPL be possible? HOT 1
- Feature request: Add syntax sugar for dictionary access HOT 3
- Exit from script early? HOT 2
- Odd behaviour with overwrite then append in command block HOT 1
- Publish vscode extension to open-vsx HOT 2
- Feature: Add print() function with no newline HOT 3
- Parse error when std.import'ed script contains executable statements HOT 3
- Feature: Add symbols for interpreter, program, and script HOT 3
- Feature: Add 'File' support that can cross the curly-block barrier HOT 1
- Feature: Add support for multi-way conditional(s) HOT 1
- Question: std.catch with parameters HOT 4
- Running script has no output unless run inside another program HOT 7
- Test using `capture.hsh` fails HOT 7
- Feature: Potential for bash transpilation? HOT 1
- External: Neovim syntax highlighting and static checks HOT 1
- Regex doesn't work due to UTF-8 HOT 2
- [Suggestion] Add global prelude HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hush.