ArgParse - Customizing Group Commands

Building Command Line Tools with Python, Julia and Nodejs Module 02 - Building Command Line Tools in Python with ArgParse
6 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€65.86
List Price:  €94.09
You save:  €28.23
£56.23
List Price:  £80.33
You save:  £24.10
CA$96.56
List Price:  CA$137.95
You save:  CA$41.39
A$109.12
List Price:  A$155.90
You save:  A$46.77
S$95.51
List Price:  S$136.45
You save:  S$40.93
HK$548.13
List Price:  HK$783.08
You save:  HK$234.94
CHF 63.91
List Price:  CHF 91.31
You save:  CHF 27.39
NOK kr769.36
List Price:  NOK kr1,099.13
You save:  NOK kr329.77
DKK kr491.41
List Price:  DKK kr702.04
You save:  DKK kr210.63
NZ$118.95
List Price:  NZ$169.94
You save:  NZ$50.98
د.إ257.03
List Price:  د.إ367.20
You save:  د.إ110.17
৳7,677.69
List Price:  ৳10,968.60
You save:  ৳3,290.91
₹5,852.52
List Price:  ₹8,361.11
You save:  ₹2,508.58
RM335.39
List Price:  RM479.15
You save:  RM143.76
₦84,069.65
List Price:  ₦120,104.65
You save:  ₦36,035
₨19,458.35
List Price:  ₨27,798.84
You save:  ₨8,340.48
฿2,566.81
List Price:  ฿3,667.03
You save:  ฿1,100.22
₺2,274.04
List Price:  ₺3,248.77
You save:  ₺974.73
B$362.90
List Price:  B$518.45
You save:  B$155.55
R1,334.09
List Price:  R1,905.92
You save:  R571.83
Лв128.84
List Price:  Лв184.07
You save:  Лв55.22
₩97,476.14
List Price:  ₩139,257.60
You save:  ₩41,781.46
₪264.05
List Price:  ₪377.23
You save:  ₪113.18
₱3,986.52
List Price:  ₱5,695.28
You save:  ₱1,708.75
¥10,820.22
List Price:  ¥15,458.12
You save:  ¥4,637.90
MX$1,176.64
List Price:  MX$1,680.99
You save:  MX$504.34
QR256.17
List Price:  QR365.97
You save:  QR109.80
P968.93
List Price:  P1,384.25
You save:  P415.31
KSh9,203.68
List Price:  KSh13,148.68
You save:  KSh3,945
E£3,396.13
List Price:  E£4,851.82
You save:  E£1,455.69
ብር3,996.71
List Price:  ብር5,709.83
You save:  ብር1,713.12
Kz58,375.11
List Price:  Kz83,396.59
You save:  Kz25,021.47
CLP$68,085.57
List Price:  CLP$97,269.27
You save:  CLP$29,183.70
CN¥506.62
List Price:  CN¥723.78
You save:  CN¥217.15
RD$4,150.97
List Price:  RD$5,930.22
You save:  RD$1,779.24
DA9,438.91
List Price:  DA13,484.73
You save:  DA4,045.82
FJ$159.47
List Price:  FJ$227.82
You save:  FJ$68.35
Q544.72
List Price:  Q778.21
You save:  Q233.48
GY$14,635.04
List Price:  GY$20,908.09
You save:  GY$6,273.05
ISK kr9,925.28
List Price:  ISK kr14,179.58
You save:  ISK kr4,254.30
DH711.08
List Price:  DH1,015.88
You save:  DH304.79
L1,245.82
List Price:  L1,779.82
You save:  L534
ден4,054.16
List Price:  ден5,791.90
You save:  ден1,737.74
MOP$564.11
List Price:  MOP$805.91
You save:  MOP$241.79
N$1,331.93
List Price:  N$1,902.84
You save:  N$570.91
C$2,585.77
List Price:  C$3,694.12
You save:  C$1,108.34
रु9,338.47
List Price:  रु13,341.25
You save:  रु4,002.77
S/260.34
List Price:  S/371.93
You save:  S/111.59
K265.89
List Price:  K379.86
You save:  K113.97
SAR262.53
List Price:  SAR375.07
You save:  SAR112.53
ZK1,761.48
List Price:  ZK2,516.51
You save:  ZK755.02
L327.75
List Price:  L468.24
You save:  L140.48
Kč1,662.75
List Price:  Kč2,375.47
You save:  Kč712.71
Ft26,013.66
List Price:  Ft37,163.97
You save:  Ft11,150.30
SEK kr766.89
List Price:  SEK kr1,095.61
You save:  SEK kr328.71
ARS$60,771.68
List Price:  ARS$86,820.40
You save:  ARS$26,048.72
Bs485.46
List Price:  Bs693.54
You save:  Bs208.08
COP$270,888.64
List Price:  COP$387,000.37
You save:  COP$116,111.72
₡35,184.52
List Price:  ₡50,265.75
You save:  ₡15,081.23
L1,734.30
List Price:  L2,477.69
You save:  L743.38
₲518,216.96
List Price:  ₲740,341.68
You save:  ₲222,124.71
$U2,722.73
List Price:  $U3,889.78
You save:  $U1,167.05
zł285.58
List Price:  zł407.99
You save:  zł122.40
Already have an account? Log In

Transcript

All right, so welcome back again. So in this session of the course, we'll be trying to see how to customize our groups with another feature in. So let's see what I mean by customizing our group. So in the videos like this particular, we usually have two different options, right? You have our option argument and our question argument. So in case I run it again, like Python three, in basic ci, let's help everyone to see that it's going to divide them into two different paths, right, you could have an optional session, which is an optional commit and give those a position argument, which is going to keep it as a positional commit.

So what if you want to actually customize that particular group? So let's see how to work with it. I'm just going to create a file and I will save that file as a custom group right there trying to create a custom group, see li.pi. And the basic idea behind what we're trying to do. Now let's see the busy stuff we do. So I'm just going to import a bus Then go to CUDA main function as, as always, then we are going to close our function evening.

So everything is going to be in between this. So let's create our first parser. It's going to be parser, then vertical pass fragment parser. I'm going to keep it a description. So let me expand it to let you see tool description. Going to be the SA, cause customizing groups, right?

Something very basic. If it didn't go to, at least on the face, I'd made the adding an option argument going to be an option argument would have a position argument. Then we're going to have our custom argument, right. So let's see how to upgrade. So the first one is to create a simple optional commit that's related to Don't screw it up. But David's going to give it to most of the admins, right?

Put a long form and put it short form language to keep it good to be specify your first name by your first name. Very interesting that is going to be for our optional argument. Now let's go on and create a positional argument to let's call this pata. But our argument can push an argument doesn't go with the dash dash is going to go straight away with the need to let's give it us a ch. Right then move on to help. We're going to be specify.

Specify your age, right, something like that. Then we'll give you the default to default. To go to 8020. Very easy to read. Even if you don't supply it's going to give us an object If I see this one now, in less combat in Krita new space, so x, x is going to be closer to past X to pass x, right. So that's one of the mistakes you always make you right supposed to be past it and then we can actually print out if a print is going to record.

Let's save it. And let's run it and see what you have done so far. But come back around it around numbers go up to Python, then I can't read anymore, the app is going to be our custom group. There's a hope. You're going to see the various ways to be this popular to keep us in the arrow. We have a policy document which is each and then you have an option argument, but don't add another argument to it right which is stumped.

So let's see how to dress to just the simplest we're just going to go to whatever place you go to places So let's go to custom group admit, in this case going to be our group, then I'm going to pass enough passer to add a comment group that is a basic idea of going through, then I'll give you the name that I want to apply to this name can be any name. So let's give it as we see a transition transition right into like that authentication 10 to occasion. And the very basic, then from here, and you cannot supply the particular auction argument I wanted to point to be crude, and that is custom group by so let's see what I want you to be a group. Those are ultimate passing who would be the best user. Right, that's going to be the first one and then let's give it the short format also.

That's you Good, Ellen, this is going to be another group. But I'll go with C password dash P. So let's see this one, let's see what you have. If I come back and I run it again, so you notice that this one has pushed an argument optional. But by adding this group around, it's good to have three different ones. We have a particular argument here, at the top here, you have an absurd argument here, including the first name, you have an authentication, which is a custom group, right? That is one of the ways of adding your own custom group to it.

And it's also going to work like the normal one. So in case I want to run it, it's going to work just like the previous one. So let's run it and see. So we already have it like this, right? The thing is, I want to run it and actually run it like as an option argument by going with this option. So let's give this first name.

First Name going to be in an industry once a, let's say, David, that by default, you already have Default Value policy with us 20. There now I can actually go to the limit it is going to make it right. So we set a password is not a user is not the case, I want to use that one. So go back to the same option, then go read user deep and then password. Just give it in 12345. Right?

It's going to work for us, there is a big idea about how to add your own custom group. So in a nutshell, what you do is that you just going to do the normal stuff you have been doing, you input a pass, then you create your main apasa. Then in case you want to create a customized group passages, go eat pasta with an argument group right then just supply the name of it and actually also add some other aspect to it, too. Thank you for watching and see you next session. Stay blessed.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.