CLICK - How to show help recursively

Building Command Line Tools with Python, Julia and Nodejs Module 02 - Building Command Line Tools in Python with CLICK
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.68
List Price:  €93.84
You save:  €28.15
£56.66
List Price:  £80.95
You save:  £24.28
CA$95.92
List Price:  CA$137.04
You save:  CA$41.11
A$108.49
List Price:  A$154.99
You save:  A$46.50
S$95.39
List Price:  S$136.27
You save:  S$40.88
HK$548.43
List Price:  HK$783.50
You save:  HK$235.07
CHF 63.83
List Price:  CHF 91.19
You save:  CHF 27.36
NOK kr770.92
List Price:  NOK kr1,101.37
You save:  NOK kr330.44
DKK kr490.07
List Price:  DKK kr700.13
You save:  DKK kr210.06
NZ$118.44
List Price:  NZ$169.21
You save:  NZ$50.76
د.إ257.05
List Price:  د.إ367.23
You save:  د.إ110.18
৳7,675.43
List Price:  ৳10,965.37
You save:  ৳3,289.94
₹5,833.71
List Price:  ₹8,334.23
You save:  ₹2,500.52
RM334.55
List Price:  RM477.95
You save:  RM143.40
₦87,974.63
List Price:  ₦125,683.43
You save:  ₦37,708.80
₨19,463.37
List Price:  ₨27,806
You save:  ₨8,342.63
฿2,592.21
List Price:  ฿3,703.32
You save:  ฿1,111.11
₺2,281.84
List Price:  ₺3,259.92
You save:  ₺978.07
B$361.60
List Price:  B$516.59
You save:  B$154.99
R1,346.51
List Price:  R1,923.67
You save:  R577.16
Лв128.31
List Price:  Лв183.31
You save:  Лв54.99
₩96,439.05
List Price:  ₩137,775.97
You save:  ₩41,336.92
₪264.71
List Price:  ₪378.18
You save:  ₪113.46
₱4,028.06
List Price:  ₱5,754.62
You save:  ₱1,726.55
¥10,834.45
List Price:  ¥15,478.45
You save:  ¥4,644
MX$1,198.27
List Price:  MX$1,711.89
You save:  MX$513.62
QR255.04
List Price:  QR364.36
You save:  QR109.32
P968.68
List Price:  P1,383.88
You save:  P415.20
KSh9,413.65
List Price:  KSh13,448.65
You save:  KSh4,035
E£3,365.09
List Price:  E£4,807.48
You save:  E£1,442.38
ብር3,981.35
List Price:  ብር5,687.89
You save:  ብር1,706.54
Kz58,437.56
List Price:  Kz83,485.81
You save:  Kz25,048.25
CLP$66,674.57
List Price:  CLP$95,253.47
You save:  CLP$28,578.90
CN¥507.20
List Price:  CN¥724.60
You save:  CN¥217.40
RD$4,125.63
List Price:  RD$5,894.01
You save:  RD$1,768.38
DA9,411.41
List Price:  DA13,445.45
You save:  DA4,034.04
FJ$159.39
List Price:  FJ$227.71
You save:  FJ$68.32
Q544.08
List Price:  Q777.29
You save:  Q233.21
GY$14,631.85
List Price:  GY$20,903.54
You save:  GY$6,271.69
ISK kr9,872.78
List Price:  ISK kr14,104.58
You save:  ISK kr4,231.80
DH709.20
List Price:  DH1,013.18
You save:  DH303.98
L1,247.93
List Price:  L1,782.83
You save:  L534.90
ден4,043.10
List Price:  ден5,776.11
You save:  ден1,733
MOP$564.45
List Price:  MOP$806.39
You save:  MOP$241.94
N$1,335.12
List Price:  N$1,907.39
You save:  N$572.27
C$2,574.01
List Price:  C$3,677.32
You save:  C$1,103.30
रु9,327.88
List Price:  रु13,326.11
You save:  रु3,998.23
S/257.70
List Price:  S/368.16
You save:  S/110.46
K265.79
List Price:  K379.71
You save:  K113.92
SAR262.52
List Price:  SAR375.04
You save:  SAR112.52
ZK1,806.09
List Price:  ZK2,580.25
You save:  ZK774.15
L326.86
List Price:  L466.96
You save:  L140.10
Kč1,659.60
List Price:  Kč2,370.96
You save:  Kč711.36
Ft25,883.91
List Price:  Ft36,978.60
You save:  Ft11,094.68
SEK kr762.07
List Price:  SEK kr1,088.71
You save:  SEK kr326.64
ARS$61,049.92
List Price:  ARS$87,217.91
You save:  ARS$26,167.99
Bs484.99
List Price:  Bs692.87
You save:  Bs207.88
COP$273,464.60
List Price:  COP$390,680.46
You save:  COP$117,215.86
₡35,005.20
List Price:  ₡50,009.58
You save:  ₡15,004.37
L1,726.48
List Price:  L2,466.51
You save:  L740.02
₲518,221.78
List Price:  ₲740,348.57
You save:  ₲222,126.78
$U2,696.53
List Price:  $U3,852.35
You save:  $U1,155.82
zł283.79
List Price:  zł405.43
You save:  zł121.64
Already have an account? Log In

Transcript

All right. So welcome back again. So in this particular session, we try to see how to build a very simple way of showing all the help for each and every comment. So normally if you go to your update your build this issue help that help is going to list the physical right for us. So in case you want to know the help documentation for this one, you have to bring it in this particular option of capitalized as hope then can see the help for that one, right? So this is in late.

So what if you want to show all the help for the user right? So that they better we have to see every form of help in every form of usage of this particular CLR. So how do you do that? So let's see how to write a simple function out of the box to help us do that. So I'm just going to come to the top of my file and create a function call because it helped. Chris See, hope.

Then I'm going to pass in some video stuff right. So this, how to work with it. Would you go to CMD for the command, then uncle, which parent says to not the basic ID for our function, then the next option is going to be supplying the contest, which is going to be from our way of using contest. We'll click CTS contest. Then I'll pass the mic, click cool. And now is the corridor now passing my buddies right so there's the big idea.

So click that call contest because you're picking the contest then are supplying some viewers arguments with the advent of supplying the command is coming from here. Let me expand to the veto, which is coming from here. The next option is going to be some information about it twice. So let's go to a full name which is going to be the CMD name. CMD writes very busy So this is going to be the command name. So this is going to help us to get the particular command name itself, and then going to give us information about it right as a basic idea.

So that is it. let's admit that nest in the limited supply the parent to be equal to our period. That is what we need. So we are using this particular contest to help us do a recursive help to fetch all the views held for this particular app. So let's work on it. So let's print command now, to print CMD to get out of the post, so our distance is coming.

By default from click like that, the basic idea, then go to print our space, then you're going to move on in good command and available political invoice command and then we're going to go with the get attribute then would supply the CMD. Then next, we're going to be the commands that you want to supply so CMD I'm just going to put in a command Then how supply. Additionally, something very easy except a very simple that is a command variable to be grouping tree. So first up in my commands dot value. Since this is a dictionary now then I'm going to iterate up to be recursive. So if you have learnt about recursion before, we are running the same file at the end of it.

So let's just go over and over again. So recursive help, then our sub, then our contest, but there is something very basic. So if I save it now, and now to see this particular function, we have to come to my main function down here and then create another function to run around it right. So let's go with this buttload of main command. there let's create this particular function call to show or help to show every show or the help writing contest, the show all the help or to help in our supply particular function because it will now pass in my main function. So the mean is coming from our main function here, right.

So let's save it. Let's run it again. Let's see what we have done. So I'll come back to our help. Now, we have our show help here, then I can actually run this show help again to go issue help. Go to print or the Bureau's help information about it to give us an arrow because of something we missed something is supposed to be values, right?

What value because a dictionary. So this supposed to be values. So let's print again. Now it is showing us every particular help, it permits you to Sweetie, but the basic information about this, there's going to pick one of them that is the reverse, give us how to use it and pick the capitalize give us how to write that is the basic idea behind the show, even together with the show hope so. So in a nutshell, with this recursive help, you can get all the various help information about it. So this is a PC idea go to create a contest, you're going to the command and then the command name itself a print command, then you're going to get the whole for that particular contest that you have chosen, then we're going to create a dictionary, we're just going to narrow it down to that particular dictionary.

And then rando Casey helped me get over that. But then finally, we come back to displace, and then pass our main function behind are critical and the basic idea behind so let's try the same scenario done on one of the command that we did. So which was a subgroup CLR, which is this particular sub CLR to I just copy the function here, same function up that it took off our subgroup here. Right, then we are going to pass the last stuff here is going to be sure to pass it. The bottom. There, let's give it a description.

It's going to be Sure oil in the show, oh, help. Delighted if I save it now to our subscription. So I don't read a sub option does that help you be seeing the real stuff so we have our shoe help shoe all help. And I can run it from here as show, help, show help going to print every one of the help for us. Very, very interesting and very, very informative. So that is how to work with crazy folk to show each and every help message for our entire coma, not only just for the commands, but we're going to iterate through it and go to each and every one of them.

Give us the information for their base information for each and every one of them. Thank you for watching, and see you in the 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.