Commit graph

717 commits

Author SHA1 Message Date
Knight
c2fb66dfcb uucore::utmpx: fix doctest errors 2016-08-20 02:55:17 +08:00
Knight
bc61634dba tr: use HashMap in stdlib instead of vec_map 2016-08-20 02:25:55 +08:00
Nathan Ross
9d2616442a Merge pull request #963 from alsuren/sort--merge
Implement sort  --merge
2016-08-12 20:42:30 -04:00
David Laban
cf93826eee sort --check refactor to use iterator
This allows us to check files without bringing them entirely into
memory. Also makes it easier to find the disorder in
    (seq 9; echo 0) | sort --check
(points at the end of the file, where our previous version would
point at the start of the file)

Itertools' .coalesce() was the most useful helper that I could find
for comparing adjacent values in an iterator. It is designed for
implementing things like .dedup(), so the resulting code is a little
unintuitive.
2016-08-13 00:42:44 +01:00
David Laban
3531c46fb8 sort --merge --unique
This uses Itertools' dedup() rather than Vec::dedup(). There is probably
a cleaner, more polymorphic way to do this. Suggestions welcome.
2016-08-13 00:42:44 +01:00
David Laban
e1af1520e7 sort: make compare_by honour settings.reverse
This allows sort --merge --reverse to work as well.
2016-08-13 00:42:43 +01:00
David Laban
8a8319a337 sort --merge works, but ignores --unique and --reverse
FileMerger receives Lines Iterables of the pre-sorted input files
via push_file() It implements Iterator, which yields lines from the
input files in (merged) sorted order. If the input files are not sorted,
then the behavior is undefined.

Internally, FileMerger uses a
std::collections::BinaryHeap<MergeableFile>.

MergeableFile is an internal helper that implements Ord in a way that
BinaryHeap can use (note that we want smallest-first, but BinaryHeap
returns largest first, so MergeableFile::cmp() calls reverse() on
whatever compare_by() returns.
2016-08-13 00:42:43 +01:00
David Laban
76abc7e51d sort: refactor compare_fns into Settings
Also split out a compare_by(a, b, settings) helper function,
which may be used by --merge, later.
2016-08-13 00:26:20 +01:00
Knight
f19d361013 uniq: add test for case-insensitive comparison 2016-08-13 02:04:19 +08:00
Knight
0ea5314ea1 uucore: make libc optional 2016-08-13 02:00:20 +08:00
mpkh
96e8748336 Merge pull request #945 from nathanross/cut-fix-chars-ranges
cut: make chars mode use byte mode behavior
2016-08-12 04:56:47 +00:00
nathanross
f2dc230d0e uucore: coreopts alignment, spacing, and optional usage 2016-08-11 23:20:39 -04:00
Nathan Ross
4a2532fc12 cut: chars mode has same behavior as byte mode 2016-08-11 18:49:20 -04:00
Nathan Ross
2e41535d69 pinky: switch to using new coreopts syntax 2016-08-11 14:37:26 -04:00
Nathan Ross
6ecf9ecf66 who: switch to using new coreopts syntax 2016-08-11 14:37:25 -04:00
Nathan Ross
617e8ca682 arch: switch to using new coreopts syntax 2016-08-11 14:37:25 -04:00
Nathan Ross
e019b2657e cut: switch to using new coreopts syntax 2016-08-11 14:37:24 -04:00
Nathan Ross
f8509240df uucore: require version; syntax; summary; longhelp 2016-08-11 14:37:16 -04:00
Knight
87894dedca who: implemented 2016-08-11 15:41:28 +08:00
Knight
18da533538 uucore::utmpx: change API and fix error 2016-08-11 15:41:12 +08:00
Knight
8c6cd72848 who: add entries 2016-08-11 00:19:26 +08:00
Knight
963ab9d321 users: use uucore::utmpx 2016-08-10 15:24:55 +08:00
Knight
f4c50921d8 uptime: use uucore::utmpx 2016-08-10 15:24:45 +08:00
Knight
77ef1580c2 pinky: use uucore::utmpx 2016-08-10 15:24:29 +08:00
Knight
301a240b73 uucore::utmpx: refine implementation 2016-08-10 15:23:07 +08:00
Knight
163a3a2540 coreopts: fix error when using msg_wrong_number_of_arguments macro 2016-08-10 13:59:30 +08:00
Knight
23979542af uucore: conditional enable different features 2016-08-10 13:57:40 +08:00
Knight
c9dde462c7 uucore: export latest libc 2016-08-10 01:00:39 +08:00
Knight
7d5a4dbf20 coreopts: display package name instead of module path 2016-08-10 00:16:06 +08:00
Nathan Ross
5aaff02195 cut: implement zero-terminated option
no changes to char mode because removal
of specialized char mode behavior is pending
2016-08-08 20:15:53 -04:00
Nathan Ross
1bf2c82520 arch: use message templates for consistent, original-work error handling 2016-08-08 04:36:33 -04:00
Nathan Ross
d56389aca0 cut: use message templates for consistent error UX 2016-08-08 04:32:48 -04:00
Nathan Ross
3eb9bbf4b5 uucore: CoreOptions error and version message templates 2016-08-08 04:29:11 -04:00
Nathan Ross
c91fd51197 uucore: add message templates 2016-08-08 03:05:36 -04:00
Nathan Ross
ea6b0e55ad cut: provide original-work help message and option descriptions 2016-08-07 23:16:15 -04:00
Chris Nikkel
cdfdc3a2bd uniq: add command line option -z for zero terminated input and output 2016-08-06 18:41:47 -07:00
Knight
0d48744c0f base64: simplified 2016-08-07 00:41:53 +08:00
Knight
9c7ff133dc base32: implemented 2016-08-07 00:41:52 +08:00
Knight
276d2ccd53 uucore: add module encoding 2016-08-07 00:41:52 +08:00
Knight
7c5416799e base32: add entries 2016-08-06 11:45:03 +08:00
Corey Farwell
01da600f71 Remove unused variable binding. 2016-08-05 09:06:39 -04:00
Corey Farwell
8fe3eac087 Remove unused imports. 2016-08-05 09:05:12 -04:00
Corey Farwell
eca7543c61 Cleanup logic around wait_or_timeout exit status handling. 2016-08-04 21:30:50 -04:00
Nathan Ross
a8f5b430df Merge pull request #935 from frewsxcv/refactor-time
Prefer handling `Duration` over `f32` when dealing with times.
2016-08-04 21:17:38 -04:00
Corey Farwell
99fda0b716 Prefer handling Duration over f32 when dealing with times.
Also refactored out usage of the `time` crate in `uucore`.
2016-08-04 19:21:30 -04:00
Knight
d4ac9f22fc uptime & users: move functions extern to uucore::utmpx 2016-08-04 23:39:30 +08:00
Knight
833d50e192 pinky: obtain correct timestamp 2016-08-04 23:39:30 +08:00
Knight
0020d5c80c uucore: update utmpx 2016-08-04 22:37:54 +08:00
Corey Farwell
160f7ed5f4 Use setpgid from libc. 2016-08-04 08:34:33 -04:00
David Laban
6751d2c708 implement sort --stable
Made a new function sort_by(lines, compare_fns), which accepts a
list of compare_fns and calls lines.sort_by() with a closure that
calls each compare_fn in turn until one returns something other
than equal.

Default behavior ensures that String::cmp is the last element in the
compare_fns list (referred to as 'last resort' sorting by man sort).
Passing --stable (-s) turns this behaviour off.

Test cases provided for `sort --month` and `sort --month --stable`.
2016-08-03 07:56:40 +01:00
Mark Karasek
59ad388cce ls: remove dependence on nightly 2016-07-29 07:07:38 -07:00
Mark Karasek
900cd41eb6 ls improvments
* Add options -c, -F, -L, -l, -r, -R, -S, -t, -U, --color
* Fix options -a, -A
* Remove unused options
* Output in columns when not using -l
* Output date with -l
2016-07-28 17:41:52 -07:00
Kevin Robert Stravers
5226ba963c ls: Implement the '-a' (all) flag
The all flag did not cull/remove the directory entries starting with a
dot. The help message indicates it should. The implementation checks
if the string starts with a dot whilst also using '-a' to determine
whether a DirEntry is to be printed.
2016-07-27 11:29:27 +02:00
Kevin Robert Stravers
0afe9b347e ls: Show columns correctly padded according to the largest file and the largest symlink count 2016-07-26 16:05:20 +02:00
mpkh
da0de488e6 Merge pull request #913 from knight42/pinky
Implement pinky
2016-07-26 13:38:53 +04:00
Knight
be20d8605d pinky: add tests 2016-07-26 17:26:22 +08:00
Knight
6fff3a7665 pinky: cleanup the code 2016-07-26 16:44:30 +08:00
Knight
e0c950e145 pinky: canonicalize host 2016-07-26 16:44:30 +08:00
Knight
f91c60ff70 pinky: fix a weird bug:
Strings passed to C functions must ends with NULL.
2016-07-26 16:44:30 +08:00
Knight
048daee8b9 pinky: make ci happy 2016-07-26 16:44:30 +08:00
Knight
fe952d90d8 pinky: iterate over utmp structs using getutxent() 2016-07-26 16:44:29 +08:00
Knight
1056542dd3 uucore::utmpx: revert the changes 2016-07-26 16:44:29 +08:00
Knight
3ed49033b7 pinky: implement short format 2016-07-26 16:44:25 +08:00
Knight
7fb3eef5e5 pinky: implement long format 2016-07-26 16:44:25 +08:00
king6cong
ff7d2bae16 skip directory tail 2016-07-23 23:03:00 +08:00
Jeremy Neptune
a3004fbbff
cp: added -v/--verbose flag
I forgot that -v refers to "verbose" and not "version"
when making earlier changes. So I fixed that and for
good measure added the verbose flag anyway.
2016-07-15 14:41:50 -04:00
Jeremy Neptune
cc57ce7699
cp: added -T/--no-target-directory flag 2016-07-15 14:08:04 -04:00
Jeremy Neptune
5e03b7c75d
cp: Added -t flag, and fixed path bug for source files.
* Added flag -t/--target-directory
* No longer assumes that the source arguments are files in the CWD (in other words, can copy files from directories other than CWD)
2016-07-15 13:15:05 -04:00
Ben Eills
28d1de1de0 Fix type synonym relaiance which breaks some rusts 2016-07-13 15:51:41 +02:00
Ben Eills
fa2145bb84 Allow specification of mode strings for install
We now accept symbolic and numeric mode strings using the
--mode or -m option for install.  This is used either when
moving files into a directory, or when creating component
directories with the -d option.  This feature was designed
to mirror the GNU implementation, including the possibly
quirky behaviour of `install --mode=u+wx file dir`
resulting in dir/file having exactly permissions 0300.

Extensive integration tests are included.

This chnage required a higher libc dependency.
2016-07-13 15:29:24 +02:00
Ben Eills
b15fff6269 Implement creation of component directories (-d option)
Tested in two integration test:

 - One creating three component directories
 - One trying to create an already existing directory
2016-07-13 12:56:30 +02:00
Ben Eills
823ffbd1dd Copy rather than move files
Test this with one integration test.  Also document functions
and add an '(unimplemented)' marker to some arguments in help.
2016-07-13 12:27:11 +02:00
Ben Eills
a5d97323db Test for unimplemented command line arguments
We check if the user has given one of the (many)
not yet implemented command line arguments.  Upon
catching this, we display the specific transgressor
to stderr and exit with return code 2.

This behaviour is tested in one new integration test.
2016-07-13 10:37:08 +02:00
Ben Eills
8a5719561d Implement basic installation of file to directory
Bare minimum functionality of `install file dir` implemented.
Also added TODO markers in code for outstanding parameters
and split main function into smaller logical chunks.
2016-07-12 22:58:44 +02:00
Ben Eills
e72ec4a5bb Implement skeleton install utility
Add install utility skeleton source, based on
mv, including the getopts setup mirroring
GNU's `man install` documentation.  Also
add a single test and build system code.
2016-07-12 20:56:21 +02:00
mpkh
61cf4e4fba Merge pull request #906 from knight42/chown
Implement chown
2016-07-10 19:01:03 +04:00
Knight
197e7787a8 chown: follow symlinks correctly 2016-07-10 21:32:07 +08:00
Smigle00
35fec95d60 arch: add new utility
Signed-off-by: Smigle00 <smigle00@gmail.com>
2016-07-10 00:48:10 +05:30
Knight
7e4a708e7c chown: refactor 2016-07-04 22:50:22 +08:00
Knight
d4b2766c4b chown: Add crate walkdir 2016-06-27 23:22:13 +08:00
Knight
04d7f81fd3 chown: Almost done
TODO:
* [ ] Describe changes according to verbosity
* [ ] More tests
* [ ] Clean up the code
2016-06-22 21:40:31 +08:00
Knight
59ed78209a chown: Add mod passwd 2016-06-22 21:39:01 +08:00
Knight
123175d577 chown: Add main.rs 2016-06-22 21:37:40 +08:00
Knight
69beb787d1 chown: Add entries 2016-06-22 21:36:50 +08:00
Knight
7423c5e644 chmod: fix #831 2016-06-19 22:52:56 +08:00
Neel Kowdley
519c1caa23 add verbose flag to tail 2016-06-18 14:44:05 -04:00
Heather
3a3fbc2840 Merge pull request #901 from knight42/mktemp-dir
Improve mktemp
2016-06-18 18:16:22 +04:00
Knight
bb3536bf14 mktemp: respect quiet option 2016-06-18 17:54:52 +08:00
Knight
c53fa53c75 mktemp: rustfmt 2016-06-18 17:54:52 +08:00
Knight
c6897da7f0 mktemp: make temp dir 2016-06-18 17:54:52 +08:00
Heather
2c65aad3cf Merge pull request #900 from knight42/reorganize-tests
Reorganize tests
2016-06-17 19:45:50 +04:00
Knight
5dba86dfa2 dircolors: extract shell name from $SHELL properly 2016-06-17 21:54:44 +08:00
Knight
2758455d73 stat: fix unstable library 2016-06-17 18:30:08 +08:00
Knight
13d06ff800 dircolors: reorganize tests 2016-06-17 16:17:22 +08:00
Knight
02dc461cf8 stat: implement ' format directive & add tests 2016-06-17 16:15:50 +08:00
Knight
d46a02b586 mknod: remove repeated macro 2016-06-17 13:27:19 +08:00
Tshepang Lekhonkhobe
80432e2b94 comm: remove unused import 2016-06-15 19:42:05 +02:00
palaviv
3fd8136423 sort: Support check 2016-06-14 22:21:30 +03:00
palaviv
3bc5a5f769 sort: support multiple input files 2016-06-14 21:25:29 +03:00
palaviv
87455f998a sort: Version sort support 2016-06-14 20:33:09 +03:00