Dumb Bird
Dumb Bird
PDProgram Dream
Created by Dumb Bird on 1/23/2024 in #🔨┃dev-logs
Zarg
All the flags are parsed but you choose how and when to handle them
92 replies
PDProgram Dream
Created by Dumb Bird on 1/23/2024 in #🔨┃dev-logs
Zarg
Arguments matter; flags won't. Well, actually, it's really due to the programmer
92 replies
PDProgram Dream
Created by Dumb Bird on 1/23/2024 in #🔨┃dev-logs
Zarg
As for the error, this would return? Who knows...
92 replies
PDProgram Dream
Created by Dumb Bird on 1/23/2024 in #🔨┃dev-logs
Zarg
Due to this section, I'm hesitant to add support for --file = foo.txt
92 replies
PDProgram Dream
Created by Dumb Bird on 1/23/2024 in #🔨┃dev-logs
Zarg
Both of the featured outlined here are supported
92 replies
PDProgram Dream
Created by Dumb Bird on 1/23/2024 in #🔨┃dev-logs
Zarg
As to what is currently supported, I'll quote a section from CLIG:
- Arguments, or args, are positional parameters to a command. For example, the file paths you provide to cp are args. The order of args is often important: cp foo bar means something different from cp bar foo. - Flags are named parameters, denoted with either a hyphen and a single-letter name (-r) or a double hyphen and a multiple-letter name (--recursive). They may or may not also include a user-specified value (--file foo.txt, or --file=foo.txt). The order of flags, generally speaking, does not affect program semantics.
92 replies
PDProgram Dream
Created by Dumb Bird on 1/23/2024 in #🔨┃dev-logs
Zarg
Simple things like these conform to CLIG, along with my ideas of a command line parser.
92 replies
PDProgram Dream
Created by Dumb Bird on 1/23/2024 in #🔨┃dev-logs
Zarg
Basic parsing is implemented. I'm working towards following CLIG guidelines as I have before. Along with my own strict rules on what will be parsed. The only reason these rules are enforced is to keep things simple. For example, duplicate flags are not allowed, period. There is no use case where a duplicate flag is practical.
92 replies
PDProgram Dream
Created by keith on 7/24/2023 in #🔨┃dev-logs
Hexdump
There's little a time where it's more valuable then just passing a flag
323 replies
PDProgram Dream
Created by keith on 7/24/2023 in #🔨┃dev-logs
Hexdump
Forcing the use of environment variables is never a good idea. Most, if not everyone, hates it.
323 replies
PDProgram Dream
Created by keith on 10/7/2023 in #🔨┃dev-logs
CookieOS
Go for it king 👑
171 replies
PDProgram Dream
Created by keith on 10/7/2023 in #🔨┃dev-logs
CookieOS
Jk I'm just hating
171 replies
PDProgram Dream
Created by keith on 10/7/2023 in #🔨┃dev-logs
CookieOS
no
171 replies
PDProgram Dream
Created by Dumb Bird on 1/23/2024 in #🔨┃dev-logs
Zarg
pretty much, yes
92 replies
PDProgram Dream
Created by Dumb Bird on 1/23/2024 in #🔨┃dev-logs
Zarg
Leveraging this compile-time duck typing allows for some crazy cool things. As a final message from me, try Zig.
92 replies
PDProgram Dream
Created by Dumb Bird on 1/23/2024 in #🔨┃dev-logs
Zarg
The compiled executable is actually running code akin to:
const Input = struct {
version: []const u8,
};

fn populateStruct(cli: anytype) !Input {
var input: Input = undefined;
input.version = try cli.getFlag();

return input;
}

const CLI = struct {
pub fn getFlag(self: CLI) ![]const u8 {
if (self.flags.get("version")) |v| {
if (@TypeOf("version") == []const u8)
return "version";
}
return error.UnknownParameter;
}
};
const Input = struct {
version: []const u8,
};

fn populateStruct(cli: anytype) !Input {
var input: Input = undefined;
input.version = try cli.getFlag();

return input;
}

const CLI = struct {
pub fn getFlag(self: CLI) ![]const u8 {
if (self.flags.get("version")) |v| {
if (@TypeOf("version") == []const u8)
return "version";
}
return error.UnknownParameter;
}
};
This is quite cool as it allows a developer to express what kinds of inputs they want their app to take intuitively without sacrificing performance. It's the opposite; doing this is relatively fast! Get more while doing less, that's something I can get behind.
92 replies