mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 21:54:40 +03:00
Userland: Use Core::ArgsParser for 'realpath'
This commit is contained in:
parent
7b82334e2f
commit
646f6165e2
Notes:
sideshowbarker
2024-07-19 04:12:06 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/646f6165e25 Pull-request: https://github.com/SerenityOS/serenity/pull/3019
@ -24,10 +24,9 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@ -37,14 +36,15 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argc != 2) {
|
||||
printf("usage: realpath <path>\n");
|
||||
return 1;
|
||||
}
|
||||
const char* path;
|
||||
|
||||
char* value = realpath(argv[1], nullptr);
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(path, "Path to resolve", "path");
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
char* value = realpath(path, nullptr);
|
||||
if (value == nullptr) {
|
||||
printf("realpath() error: %s\n", strerror(errno));
|
||||
perror("realpath");
|
||||
return 1;
|
||||
}
|
||||
printf("%s\n", value);
|
||||
|
Loading…
Reference in New Issue
Block a user