|
1 |
| -# dart tilde expansion |
| 1 | +# Tilde Expansion for Dart |
| 2 | + |
| 3 | +A simple, efficient, and reusable Dart package to expand tilde (~) paths to the user's home directory. |
2 | 4 |
|
3 |
| -A String extension to expand the ~ in a path |
4 | 5 |
|
5 | 6 | since my proposition of a modification of the path project didn't find
|
6 | 7 | favorable acknowledgment, this functionality being vital to most of my projects,
|
7 |
| -her a miniature standalone library just for this.... |
| 8 | +here a miniature standalone library just for this.... |
| 9 | + |
| 10 | +## Key Features: |
8 | 11 |
|
9 |
| -## usage |
| 12 | + Simple Usage: Easily expand tilde paths with a single method call. |
| 13 | + Works with ~/ and ~user paths, note that no verification of |
| 14 | + that user existence is done |
| 15 | + Cross-Platform Compatibility: Works seamlessly across different operating systems. |
| 16 | + Flexible Configuration: Customize expansion behavior with optional parameters. |
| 17 | + Efficient Implementation: Optimized for performance and clarity. |
| 18 | + |
| 19 | +##Installation: |
| 20 | +```bash |
| 21 | +dart pub add tilde_expansion |
10 | 22 | ```
|
11 |
| -import 'package:tilde_expansion/tilde_expansion.dart' as tilde_expansion; |
12 | 23 |
|
13 |
| -void main(List<String> arguments) { |
14 |
| -print("Hello to convert ~/Documents/test.txt to ${'~/Documents/test.txt'.expandUser()}"); |
15 |
| -} |
| 24 | +## Usage |
| 25 | +``` |
| 26 | +import 'package:tilde_expansion/tilde_expansion.dart'; |
| 27 | +
|
| 28 | +print("Expand path from ~/Documents/test.txt to ${'~/Documents/test.txt'.expandUser()}"); |
16 | 29 | ```
|
17 | 30 |
|
18 | 31 | or look at the tests, if no tilde is found nothing is done, you can actually ask to canonicalize the path
|
19 | 32 | by adding:
|
20 | 33 |
|
21 | 34 | ```
|
22 |
| -import 'package:tilde_expansion/tilde_expansion.dart' as tilde_expansion; |
| 35 | +import 'package:tilde_expansion/tilde_expansion.dart'; |
23 | 36 |
|
24 |
| -void main(List<String> arguments) { |
25 | 37 | print("Hello to convert ~/Documents/test.txt to ${'~/Documents/test.txt'.expandUser(canonicalize: true)}");
|
26 |
| -} |
| 38 | +print("Hello to convert ~toto/Documents/test.txt to ${'~toto/Documents/test.txt'.expandUser(canonicalize: true)}"); |
27 | 39 | ```
|
28 | 40 |
|
| 41 | +# Additional Notes: |
| 42 | + |
| 43 | + Error Handling: The package handles cases where the HOME environment variable is not set. |
| 44 | + Performance: The implementation is optimized for efficiency, especially when dealing with large numbers of path expansions. |
| 45 | + |
| 46 | +By using this package, you can simplify your code and make it more portable across different environments. |
0 commit comments