forked from root/public
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.9 KiB
47 lines
1.9 KiB
5 years ago
|
# options
|
||
|
|
||
|
## Instructions
|
||
|
|
||
![]()
5 years ago
|
Write a program that takes an undefined number of arguments which could be considered as `options` and writes on the standard output a representation of those `options` as groups of `bytes` followed by a newline (`'\n'`).
|
||
5 years ago
|
|
||
5 years ago
|
- An `option` is an argument that begins with a `-` and that can have multiple characters which could be :
|
||
![]()
4 years ago
|
-abcdefghijklmnopqrstuvwxyz
|
||
5 years ago
|
|
||
5 years ago
|
- All `options` are stocked in a single `int` and each `options` represents a bit of that `int`, and should be stocked like this :
|
||
5 years ago
|
|
||
5 years ago
|
- 00000000 00000000 00000000 00000000
|
||
|
- ******zy xwvutsrq ponmlkji hgfedcba
|
||
5 years ago
|
|
||
5 years ago
|
- Launching the program without arguments or with the `-h` flag activated must print all the valid `options` on the standard output, as shown on one of the following examples.
|
||
5 years ago
|
|
||
5 years ago
|
- Please note the `-h` flag has priority over the others flags when it is called first in one of the arguments. (See the examples)
|
||
![]()
5 years ago
|
|
||
5 years ago
|
- A wrong `option` must print `Invalid Option` followed by a newline.
|
||
5 years ago
|
|
||
5 years ago
|
### Usage
|
||
5 years ago
|
|
||
|
```console
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ go build
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./test | cat -e
|
||
5 years ago
|
options: abcdefghijklmnopqrstuvwxyz$
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./test -abc -ijk | cat -e
|
||
5 years ago
|
00000000 00000000 00000111 00000111$
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./test -z | cat -e
|
||
5 years ago
|
00000010 00000000 00000000 00000000$
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./test -abc -hijk | cat -e
|
||
5 years ago
|
options: abcdefghijklmnopqrstuvwxyz$
|
||
![]()
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./test -h | cat -e
|
||
|
options: abcdefghijklmnopqrstuvwxyz$
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./test -zh | cat -e
|
||
![]()
5 years ago
|
00000010 00000000 00000000 10000000$
|
||
![]()
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./test -z -h | cat -e
|
||
|
options: abcdefghijklmnopqrstuvwxyz$
|
||
![]()
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./test -hhhhhh | cat -e
|
||
|
options: abcdefghijklmnopqrstuvwxyz$
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./test -eeeeee | cat -e
|
||
|
00000000 00000000 00000000 00010000$
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./test -% | cat -e
|
||
5 years ago
|
Invalid Option$
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$
|
||
![]()
5 years ago
|
```
|